March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hey
I have a measure for cumulative total that sums up values from a certain date forward. This works as intended.
cumulative total = CALCULATE([Total]; DATESBETWEEN(Calendar[Date]; MIN('Dimension'[StartDate]); MAX(Calendar[Date])))
Now I need an another measure that shows cumulative total up until last month. Here's what I have, it seems to be close to what I look for.
cumulative total (lm) = CALCULATE([cumulative total]; DATEADD(Calendar[Date]; -1; Month))
But not quite.
Cumulative total (lm) measure works except for the very first month. That 15600 you see at January 2017 is the cumulative total for 2017 and 2018, but it should be 0 or null, since January 2017 is the first month and there is no last month available.
I appreciate all the help.
Solved! Go to Solution.
So, I toyed around with your suggestion a bit. I think I got it.
Cumulative total = CALCULATE ( [Total]; FILTER ( ALL ('Calendar'); 'Calendar'[Date] >= MIN('Dimension'[StartDate]) && 'Calendar'[Date] <= MAX('Calendar'[Date])))
This way cumulative total (lm) seems to be working and column totals aswell. I'll still have to double and triple check everything against the actual model and data. But at first glance looks alright.
Thank you for steering me the right direction. You were a great help.
@Anonymous
Try this..... But if you need Dec 2017 balance in Jan 2018 this would fail.
cumulative total (lm) = IF ( MONTH ( SELECTEDVALUE ( Calendar[Date] ) ) > 1, CALCULATE ( [cumulative total], DATEADD ( Calendar[Date], -1, MONTH ) ) )
I tried your suggestion, but every month ends up being blank. And yes I would need cumulative totals to cover multiple years.
I changed the data little bit to better illustrate the scenario. We have dimension (a project or a service or whatever) that starts on April 2017 and ends October 2018. We have a measure (cumulative total) that calculates cumulative totals from start to end without resetting (not a ytd measure) and another measure (cumulative total lm) that basically does the same but stays one month behind.
My original measures do that, with the exception of the very begin. Somehow January 2017 gets a value of 10600 which is the final value from November 2018.
HI @Anonymous
Could you share your file?
Hi @Anonymous
If you revise the Cumulative Total formula as per below, you will get the correct Cumulative Total (lm) as well.
cumulative total = CALCULATE ( [Total], FILTER ( ALL ( Calendar[Date] ), 'Calendar'[Date] <= MIN ( 'Calendar'[Date] ) && 'Calendar'[Date] >= MIN ( 'Dimension'[StartDate] ) ) )
So, I toyed around with your suggestion a bit. I think I got it.
Cumulative total = CALCULATE ( [Total]; FILTER ( ALL ('Calendar'); 'Calendar'[Date] >= MIN('Dimension'[StartDate]) && 'Calendar'[Date] <= MAX('Calendar'[Date])))
This way cumulative total (lm) seems to be working and column totals aswell. I'll still have to double and triple check everything against the actual model and data. But at first glance looks alright.
Thank you for steering me the right direction. You were a great help.
@Anonymous
In 20 seconds I was about to write this
@Anonymous
But I still donot know why your formula doesn't work for first month
I really appreciate your efforts, but unfortunately your suggestion messed up the totals. So it's a no go.
Actually the missing 2017 column totals don't matter, but the very end has to match, 10600 in this case.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
125 | |
84 | |
66 | |
55 | |
43 |
User | Count |
---|---|
199 | |
107 | |
95 | |
64 | |
56 |