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
neees78
Helper II
Helper II

Calculated column DAX for cumulative cost saving

Good day all, 

I've the following table - need daily cost to show cumulative savings after each new saving is added in 

Stating at daily cost 100K and then that column should reduce each time new saving is added in

Sorted by Target Date 

 

neees78_0-1676632530727.png

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @neees78 
Please refer to attached sample file with the proposed solution. Hope this is what you're looking for

1.png

Daily Cost = 
VAR StartingValue = 100000
VAR CurrentDate = SELECTEDVALUE ( 'Table'[Target Date] )
VAR CurrentID = SELECTEDVALUE ( 'Table'[ID] )
VAR SelectedTable = ALLSELECTED ( 'Table' )
VAR TableOnAndBefore = 
    FILTER ( 
        SelectedTable, 
        VALUE ( 'Table'[Target Date] ) * 1000000 + 'Table'[ID] 
            <= VALUE ( CurrentDate ) * 1000000 + CurrentID 
    )
VAR AccumulatedSaving = SUMX ( TableOnAndBefore, 'Table'[New Savinng] )
RETURN
    IF ( 
        HASONEVALUE ( 'Table'[ID] ),
        StartingValue - AccumulatedSaving
    )

View solution in original post

8 REPLIES 8
tamerj1
Super User
Super User

Hi @neees78 
Please refer to attached sample file with the proposed solution. Hope this is what you're looking for

1.png

Daily Cost = 
VAR StartingValue = 100000
VAR CurrentDate = SELECTEDVALUE ( 'Table'[Target Date] )
VAR CurrentID = SELECTEDVALUE ( 'Table'[ID] )
VAR SelectedTable = ALLSELECTED ( 'Table' )
VAR TableOnAndBefore = 
    FILTER ( 
        SelectedTable, 
        VALUE ( 'Table'[Target Date] ) * 1000000 + 'Table'[ID] 
            <= VALUE ( CurrentDate ) * 1000000 + CurrentID 
    )
VAR AccumulatedSaving = SUMX ( TableOnAndBefore, 'Table'[New Savinng] )
RETURN
    IF ( 
        HASONEVALUE ( 'Table'[ID] ),
        StartingValue - AccumulatedSaving
    )

@tamerj1    it worked perfectly -   thanks a lot 

tamerj1
Super User
Super User

@neees78 
Is new Saving a measure or a column? Are all columns coming from the same table?

Yes - all columns in single table , the "New Saving" is a column

@neees78 
Is new Saving a measure or a column?

the new saving is column - I just added it to explain - starts at 100K then it should reduce 

FreemanZ
Super User
Super User

hi @neees78 

do you have other columns in the dataset?

yes - Title (txt) & ID (Number) 

 

neees78_0-1676633586059.png

 

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.