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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Nikki
Helper II
Helper II

cumulative sum

hi there

i have a table called "financials". in financials there is a field called "month" (which is a date field), i also have a $ field which is called "actuals". i want to create a stacked column and line graph report which displays cumulatives over years/or months . I have added "month" as a page filter so the user can choose.

could somebody please help me the sum/query for the column or measure etc?

i have already created a nice report which displays spend per month (but cumulative would be awesome).

 

i tried to review other posts but they didnt make much sense to me sorry 😞

 

desired result below

thanks
N

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

@Nikki

MEASURE 1

Running Total =
CALCULATE (
    SUM ( financials[actuals] ),
    FILTER (
        ALLSELECTED ( financials ),
        financials[month] <= MAX ( financials[month] )
            && MIN ( financials[month] ) <= TODAY ()
    )
)

Measure 1 will give you the RT up to today - however you may still overshoot a bit if there's no data for the current month.

So to address this you may want to use Measure 2.

MEASURE 2

Running Total 2 =
IF (
    MIN ( financials[month] )
        <= CALCULATE (
            LASTDATE ( financials[month] ),
            FILTER ( ALLSELECTED ( financials ), financials[actuals] <> BLANK () )
        ),
    CALCULATE (
        SUM ( financials[actuals] ),
        FILTER (
            ALLSELECTED ( financials ),
            financials[month] <= MAX ( financials[month] )
        )
    )
)

Good Luck! Smiley Happy

View solution in original post

6 REPLIES 6
Eric_Zhang
Employee
Employee

@Nikki

According to your description, you may need some measure as below. Check more details in the attached pbix.

cumulative SUM = SUMX(FILTER(ALLSELECTED(financials),financials[month]<=MAX(financials[month])),financials[actuals])

Capture.PNG

 

If it is not exactly what you're requiring, please elaborate with more details, even better with a sample pbix.

thanks this is great, but how do i display cumualtive actuals though purely based on what is entered. i have forecast values till end of 2017 for each month, the report shows cumulative actuals till end of year too ..i need the cumulative actuals to stop based on when it was last entered..

Sean
Community Champion
Community Champion

@Nikki

MEASURE 1

Running Total =
CALCULATE (
    SUM ( financials[actuals] ),
    FILTER (
        ALLSELECTED ( financials ),
        financials[month] <= MAX ( financials[month] )
            && MIN ( financials[month] ) <= TODAY ()
    )
)

Measure 1 will give you the RT up to today - however you may still overshoot a bit if there's no data for the current month.

So to address this you may want to use Measure 2.

MEASURE 2

Running Total 2 =
IF (
    MIN ( financials[month] )
        <= CALCULATE (
            LASTDATE ( financials[month] ),
            FILTER ( ALLSELECTED ( financials ), financials[actuals] <> BLANK () )
        ),
    CALCULATE (
        SUM ( financials[actuals] ),
        FILTER (
            ALLSELECTED ( financials ),
            financials[month] <= MAX ( financials[month] )
        )
    )
)

Good Luck! Smiley Happy

Hi Sean

Can i be a pain and ask how i can resolve an issue when the user enters $0 dollars? the cumulative doesnt pick up infact it stays where it was where the actual is great than 0. below is a screenshot of what i mean.. if i change the "BLANK" to >0 i get a cumulative till end of the year with the forecast.

the project manager will from time to time enter and report zero actuals for that month..

 

thanks so much in advance :):):)

 

2017-04-11_11-40-58.png

 Thanks @Sean you are a life saver. I had the same issue I could fix it with the second measure. By the way do you know a way to do the same thing but by predefined groups? 

BhaveshPatel
Community Champion
Community Champion

Hi Nikki,

 

Please refer this DAXPATTERNS BLOG for the complete patterns of calculating cumulative total. It is one of hte most widely used formula in DAX and can solve many complex problems.

 

 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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