Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Dear all,
I have a table with a column YTD Actuals VS LY with a YTD value for each month.
I am trying to calculate a MTH Actuals VS LY from this YTD data.
To do this, I am planning to first make a measure to calculate the previous month YTD Actuals VS LY and then substract it to the YTD Actuals VS LY
To calculate the previous month YTD Actuals VS LY, here is the measure I made:
=CALCULATE([ACT_VS_LY@CR];PREVIOUSMONTH('Calendar'[date]))
As you can see in TEST measure, it is working, except that for the month of January 2021 (202101) I have the 364 from December while for January i should always have 0.
I created a date table linked to my data table.
Could you please help me find a way so that if the year of previous month is not the same as the year of my filter context, then the measure returns 0 ?
Thanks for your help !
Henri
Solved! Go to Solution.
@Hchazelle , Try a measure like
measure =
var _1 = CALCULATE([ACT_VS_LY@CR];datesMTD('Calendar'[date]))
var _2 = CALCULATE([ACT_VS_LY@CR];PREVIOUSMONTH('Calendar'[date]))
return
Switch( True() ,
not(isblank(_1) ) && not(isblank(_2) ) , _1 - _2 ,
isblank(_1) , 0,
isblank(_2),_1
)
@Hchazelle , Try a measure like
measure =
var _1 = CALCULATE([ACT_VS_LY@CR];datesMTD('Calendar'[date]))
var _2 = CALCULATE([ACT_VS_LY@CR];PREVIOUSMONTH('Calendar'[date]))
return
Switch( True() ,
not(isblank(_1) ) && not(isblank(_2) ) , _1 - _2 ,
isblank(_1) , 0,
isblank(_2),_1
)
Thanks a lot, that's perfect !
User | Count |
---|---|
91 | |
73 | |
68 | |
63 | |
55 |
User | Count |
---|---|
99 | |
88 | |
73 | |
60 | |
58 |