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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Cumulative total for last month

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.JPG

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.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Zubair_Muhammad

 

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.

 

screenshot.JPG

Thank you for steering me the right direction. You were a great help.

 

View solution in original post

9 REPLIES 9
Zubair_Muhammad
Community Champion
Community Champion

@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 ) )
)

 


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

@Zubair_Muhammad

 

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.


screenshot.JPG

HI @Anonymous

 

Could you share your file?


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

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] )
    )
)

Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

@Zubair_Muhammad

 

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.

 

screenshot.JPG

Thank you for steering me the right direction. You were a great help.

 

@Anonymous

 

In 20 seconds I was about to write this

 

Smiley Very Happy

 

 


Regards
Zubair

Please try my custom visuals

@Anonymous

 

But I still donot know why your formula doesn't work for first month

 


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

@Zubair_Muhammad

 

I really appreciate your efforts, but unfortunately your suggestion messed up the totals. So it's a no go.

screenshot.png

Actually the missing 2017 column totals don't matter, but the very end has to match, 10600 in this case.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors