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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Ajungx
Frequent Visitor

Cumulative Total Balance per Line Under Certain Conditions

InvTable

Inv. NoDateCst NameAmountPaidBalanceCumBalance
IN-00101/08/19C0011000800200200
IN-00215/09/19C0028000800800
IN-00320/09/19C00112004008001000
IN-00409/10/19C0022200100012002000
IN-00528/11/19C0033000200010001000
   820042004000 

 

What is the formula to make the measure "CumBalance"?

Balance can only be added if the customer code is the same

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @Ajungx ,

 

We can create a measure to meet your requirement.

 

CumBalance = 
CALCULATE (
    SUM ( 'Table'[Balance] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[Cst Name] = MAX ( 'Table'[Cst Name] )
            && 'Table'[Date] <= MAX ( 'Table'[Date] )
    )
)

 

CUM1.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

BTW, pbix as attached.

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-zhenbw-msft
Community Support
Community Support

Hi @Ajungx ,

 

We can create a measure to meet your requirement.

 

CumBalance = 
CALCULATE (
    SUM ( 'Table'[Balance] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[Cst Name] = MAX ( 'Table'[Cst Name] )
            && 'Table'[Date] <= MAX ( 'Table'[Date] )
    )
)

 

CUM1.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

BTW, pbix as attached.

amitchandak
Super User
Super User

@Ajungx , Try with a date table

 

Cumm = CALCULATE(SUM(Table[Balance]),filter(date,date[date] <=maxx(date,date[date])))
Cumm = CALCULATE(SUM(Table[Sales Amount]),filter(date,date[date] <=max(Table[Date])))

or

Cumm = CALCULATE(SUM(Table[Balance]),filter(allselected(date),date[date] <=maxx(date,date[date])))

or

Cumm = CALCULATE(SUM(Table[Sales Amount]),filter(allselected(Table),Table[date] <=max(Table[Date])))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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