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 measure with opening balance

Hi, 

 

My data looks like this: 

cumul.PNG

 

Is there a way to create a measure for the cumulative sum (last column in the table) that takes into account also opening balance (before January in the table). So what I would need is to sum balance and cumulative balance from previous month. Also, that when I'm using slicer for years, then in 2019 it would take the Dec cumulative balance from 2018. 

 

So far I have this measure: 

Cumulative = calculate(sum(Data[AMOUNT]);filter(ALLSELECTED(Data); Data[Month]<=MAX(Data[Month])))

 

But this doesn't take opening balance into account and when I choose a new year, then it starts cumulating the balances from 0. 

 

Thank you in advance. 

 

Best regards,

Liis

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

You show 2 Tables in your measure but your formula only refers to the Data Table.  Please share the actual data layout.  Also, the opening balance of 1500 should have some date against it.  So please assign some data to that figure.  Share data in a format that can be pasted in an Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

I could add January 2018 date to the opening balance as it should be included in January's total. But the data is from the same table, just year is different (I wanted to show that when I use year slicer on date, then it would still calculate correct cumulative). 

v-shex-msft
Community Support
Community Support

HI @Anonymous ,

I'd like to suggest you to take a look at following blog about auto-exist filter if you are using same table date field as source of slicer.

Understanding DAX Auto-Exist

I think you need to use variable to store selected and apply all function on table to ignore filter effect:

Measure =
VAR selected =
    MAX ( Table1[Date] )
RETURN
    CALCULATE (
        SUM ( Table1[Amount] ),
        FILTER ( ALL ( Table1 ), [Date] <= selected )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

This almost worked, but what is still tricky, is that I have an another slicer for different products and in case slicer is on, then it shows cumulative total for all the products (the above data was for one product only). 

 

Is there a way to add this as well in the measure? 

 

Thank you! 

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.