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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Mystery
Helper I
Helper I

Cumulative Sum using DAX

Hi,

 

I am trying to compute the cumulative sum using below DAX formula:

 

Cumulative SUM=
VAR MAXDATE = CALCULATE (value(LEFT(MAX ('Date'[DateKey]),6) ))

RETURN
IF (
LEFT(MIN('Revenue'[DateKey]),6) <= CALCULATE (LEFT(MAX ('Date'[DateKey]),6) , ALL('Date'[DateKey]) ) ,
CALCULATE (
SUM('Revenue'[ActualCount]),
ALL( 'Revenue'[DateKey]) ,
VALUE(left('Revenue'[DateKey],6)) <= MAXDATE,

'Revenue'[Col]="ABC"
)

)

 

DateKey is a column stored as YYYYMMDD.

However everytime I get the values for an individual month only and not a cumulative sum.

 

Please suggest a fix or a workaround for this.

4 REPLIES 4
v-yuta-msft
Community Support
Community Support

@Mystery ,

 

You may try modifying the measure as below:

Cumulative SUM =
VAR MAXDATE =
    VALUE ( LEFT ( MAX ( 'Date'[DateKey] ), 6 ) )
RETURN
    IF (
        LEFT ( MIN ( 'Revenue'[DateKey] ), 6 )
            <= CALCULATE ( LEFT ( MAX ( 'Date'[DateKey] ), 6 ), ALL ( 'Date' ) ),
        CALCULATE (
            SUM ( 'Revenue'[ActualCount] ),
            ALL ( 'Revenue' ),
            VALUE ( LEFT ( 'Revenue'[DateKey], 6 ) ) <= MAXDATE,
            'Revenue'[Col] = "ABC"
        )
    )

Community Support Team _ Jimmy Tao

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

Thanks but it doesnt work.

pa_trick67
Helper I
Helper I

Hi @Mystery 

I suggest you to convert this datekey into date in power query (you can use add column from example) and then compute cumulative Sum with date.

Best

Patrick

Date Key column actually holds a date in YYYYMMDD format only.

 

Also this DAX is written in tabular model and not using Power BI desktop.Thats the approach in my project.

 

The irony is although the same formula works in Power BI however does not yield correct results when written in tabular model.

 

Any pointers are appreciated.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.