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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
P567
Regular Visitor

DAX Calculation - HELP

I have this summarized dataset grouped by multiple variables.

P567_2-1694529173936.png 

This is a screenshot of a table I created from the dataset (other variables are being used as slicers), each index point has mulitple rows in the main dataset
2023 is defined as  CALCULATE(SUM('Append1'[STARTS]), 'Append1'[COMPYEAR] IN { 2023 })

2022 is defined as  CALCULATE(SUM('Append1'[STARTS]), 'Append1'[COMPYEAR] IN { 2022 })

 

I wanted to create two seperate measures each for 2023 and 2022 that will take the previous row value and then add it at each step with the current value at that index point, it should look something like this
P567_1-1694531148273.png

 


 

 

 

7 REPLIES 7
MargusMartsepp
New Member

You can create 2 separate running totals:

RunningTotal_2023 = 
VAR CurrentIndex = MAX('Table'[Index])
RETURN
CALCULATE(
    SUM('Table'[2023]),
    FILTER(
        ALL('Table'),
        'Table'[Index] <= CurrentIndex
    )
)

RunningTotal_2022 = 
VAR CurrentIndex = MAX('Table'[Index])
RETURN
CALCULATE(
    SUM('Table'[2022]),
    FILTER(
        ALL('Table'),
        'Table'[Index] <= CurrentIndex
    )
)

 

I should have cleared this ealier but the "Index" col is exactly not an index column. So I have a text field with 7 different values in it and I duplicated that col and just replaced those values with numeric values to able to sort them

sjoerdvn
Super User
Super User

You mean a running total?

RT 2023 = VAR mi=MAX(Append1'[Index]) RETURN CALCULATE(SUM('Append1'[STARTS]), 'Append1'[COMPYEAR] IN { 2023 }, 'Append1'[Index] <= mi)

I should have cleared this ealier but the "Index" col is exactly not an index column. So I have a text field with 7 different values in it and I duplicated that col and just replaced those values with numeric values to able to sort them. And using the formula you provided I see it replicating the values

P567_0-1694553063276.png

 

Well, a column is column. What isn't clear from what you've shared so far is what table that column is on, so I assumed it was in the same table. 
If that "Index" column is on some linked (dimension) table it would explain why the code I sent earlier doesn't work, you would have to change it to something like:

RT 2023 = VAR mi=MAX(SomeDimensionTable[Index]) RETURN CALCULATE(SUM('Append1'[STARTS]), 'Append1'[COMPYEAR] IN { 2023 }, SomeDimensionTable[Index] <= mi)

 

The 'Index' col is in 'Append1' table 

well, the measure works fine in my local example, so there must be other columns, filters or relationships in your model that cause the preceeding indexes to be filtered out.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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