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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to calculate YTD savings from the given table

Hello,

 

I am trying to calculate the YTD variance for my sample table shown below. 

Table Name is "Project Costs" 

 

Capture.PNG

 

I want to calculate YTD variance for this table

The formula is YTD variance = (Current month Variance) - (December month's variance of last year)

 

I used the below DAX calculation 

 

YTD_Variance = SUM('Project Costs'[Variance]) - CALCULATE(SUM('Project Costs'[Variance]), PREVIOUSMONTH('Date'[Date]))

 

This calculation works for January 2018 month, but for February 2018 it is showing wrong calculation as shown below.

 

Ca2pture.PNG

Please help me correct DAX calculation 

 

PS: I have the date dimension included. 

 

Thanks

Bhavesh

 

 

3 REPLIES 3
GilbertQ
Super User
Super User

Hi there

Just for clarification you are looking for the second part of your DAX measure to look at the DEC of the Previous Year?




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Anonymous
Not applicable

@GilbertQ yes, I think I need to change the second part of the DAX formula to get the DEC of the previous year. Any feedback and help is greatly appreciated, thanks 

Hi @Anonymous

 

You can use this measure for your Dec Variance.

 

Dec Previous Year Variance = 
VAR TodaysDate =
    NOW ()
VAR PrevYear =
    YEAR ( TodaysDate ) - 1
VAR DecPreviousYearStart =
    DATE ( PrevYear, 12, 1 )
VAR DecPreviousYearEnd =
    DATE ( PrevYear, 12, 31 )
RETURN
    CALCULATE (
        SUM( 'Project Costs'[Variance] ),
        ALL ( 'Date' ),
        'Date'[Date] >= DecPreviousYearStart
            && 'Date'[Date] <= DecPreviousYearEnd
    )

Which you can then use for your final measure by referencing this measure above.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.