The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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 !
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
104 | |
97 | |
80 | |
62 | |
57 |
User | Count |
---|---|
264 | |
120 | |
115 | |
83 | |
70 |