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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
user10456
Advocate I
Advocate I

Cumulative sum in calculated column without CALCULATE()

I want to summarise a table in my data model, and then add a cumulative count column which I can use for further analysis. I need this to be a calculated column rather than a measure. Currently, I am using SUMMARIZE() to create one table, and then using CALCULATE() and EARLIER() to create another table based on it. I would like to summarise the other table and create the running total in the same table, or otherwise not add tables to the data model. (Currently I am hiding the intermediate table, but I will have to hand this over to someone else and I'd rather avoid that if I can).

 

DAX for example tables

Raw Data = DATATABLE("Type",STRING,"Day",INTEGER,{
{"A",1},{"A",1},{"A",2},{"A",4},{"A",7},{"B",2},{"B",2},{"B",3}
})

Intermediate Table = SUMMARIZE('Raw Data', 'Raw Data'[Day], 'Raw Data'[Type],
"Count", count('Raw Data'[Day]))

Running Total =
ADDCOLUMNS('Intermediate Table', "Running Total",
CALCULATE(SUM('Intermediate Table'[Count]), ALL('Intermediate Table'),
'Intermediate Table'[Day] <= EARLIER('Intermediate Table'[Day]),
'Intermediate Table'[Type] = EARLIER('Intermediate Table'[Type])))
 

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @user10456 ,

 

not sure if i fully get you, try like:

table = 
VAR _table1 =
    ADDCOLUMNS(
        SUMMARIZE(
            'Raw Data',
            'Raw Data'[Day],
            'Raw Data'[Type]
        ),
        "Count",
        CALCULATE(COUNTROWS('Raw Data'))
    )
VAR _table2 =
ADDCOLUMNS(
    _table1, 
    "Running Total",
    SUMX(
        FILTER(_table1, [Day]<=EARLIER([Day])&&[Type]=EARLIER([Type]) ),
        [Count]
    )
)
 return _table2

 

it worked like:

FreemanZ_0-1698631599834.png

 

View solution in original post

1 REPLY 1
FreemanZ
Super User
Super User

hi @user10456 ,

 

not sure if i fully get you, try like:

table = 
VAR _table1 =
    ADDCOLUMNS(
        SUMMARIZE(
            'Raw Data',
            'Raw Data'[Day],
            'Raw Data'[Type]
        ),
        "Count",
        CALCULATE(COUNTROWS('Raw Data'))
    )
VAR _table2 =
ADDCOLUMNS(
    _table1, 
    "Running Total",
    SUMX(
        FILTER(_table1, [Day]<=EARLIER([Day])&&[Type]=EARLIER([Type]) ),
        [Count]
    )
)
 return _table2

 

it worked like:

FreemanZ_0-1698631599834.png

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.