Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
arielfmdp
Frequent Visitor

issue in day to day variance % with non consecutive dates

Hi team, I'm having a headache with this problem, I need to calculate a column with variance in percentage to previous date, BUT with non consecutive dates.

I'm getting this using

 

Var%PreviousDate =

((SUM('cnv rends-patrim-varcp'[CantCPActual]) /

  CALCULATE(

     SUM('cnv rends-patrim-varcp'[CantCPActual]);

     PREVIOUSDAY('cnv rends-patrim-varcp'[fecha])

))-1)*100

 

For example, the previous date for 19/03-16/03 doesn't work because the formula is using 18/03 instead of 16/03.

 

I should be able to get the spreadsheet aproach, look:pwoer bi issue date to date variance.png

 

 

 

 Well, that's all, I hope someone can help, I didn't find this issue on the forums.

Regards,

Ariel

1 ACCEPTED SOLUTION

@arielfmdp

 

Hi try wiyh:

 

Var%PreviousDate =
VAR fdate =
    SELECTEDVALUE ( Tabla1[Date] )
VAR ff =
    CALCULATE ( MAX ( Tabla1[Date] ); Tabla1[Date] < fdate )
RETURN
    (
        (
            SUM ( Tabla1[CantCPActual] )
                / CALCULATE (
                    SUM ( Tabla1[CantCPActual] );
                    FILTER ( ALL ( Tabla1 ); Tabla1[Date] = ff )
                )
                - 1
        )
            * 100
    )

Regards

Victor

Lima - Peru




Lima - Peru

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

 

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Sorry, I'm new Man Embarassed  here is the link to the test pbix

https://drive.google.com/open?id=1SpXqIgStbgwuvwLRhloCw_30aJ7_qww8

@arielfmdp

 

Hi try wiyh:

 

Var%PreviousDate =
VAR fdate =
    SELECTEDVALUE ( Tabla1[Date] )
VAR ff =
    CALCULATE ( MAX ( Tabla1[Date] ); Tabla1[Date] < fdate )
RETURN
    (
        (
            SUM ( Tabla1[CantCPActual] )
                / CALCULATE (
                    SUM ( Tabla1[CantCPActual] );
                    FILTER ( ALL ( Tabla1 ); Tabla1[Date] = ff )
                )
                - 1
        )
            * 100
    )

Regards

Victor

Lima - Peru




Lima - Peru

Thank you very much @Vvelarde, it worked perfectly!

I'm still have a lot to learn about DAX.

Greg_Deckler
Super User
Super User

To get the previous day, you want to find the MAX of all dates that are less than the current date. Tough to be more specific without data pasted in a way that can be copied and pasted easily (non-image). But, these two links might help, see what I do with MTBF in this article:

 

See my article on Mean Time Before Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...

 

Also, see this article:

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.