Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
I am trying to calculate the YTD variance for my sample table shown below.
Table Name is "Project Costs"
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.
Please help me correct DAX calculation
PS: I have the date dimension included.
Thanks
Bhavesh
@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.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 56 | |
| 55 | |
| 31 | |
| 17 | |
| 14 |