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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to do cummulative sum based on group and date(YTD)..

How to do cummulative sum based on group and date(YTD) using Dax.

for example : i have column yearmonth ,category ,headcount and want result as Cummulative values based on Category and YearMonth (YTD) not only previous month.I have created measure Measure 2:=CALCULATE(sumx(FILTER(Sheet1,Sheet1[YearMonth]<= max(Sheet1[YearMonth])),[Headcountmeasure])) but its not doing cummulative sum as expected.

Measure 3:=CALCULATE(SUMX(ALLEXCEPT(Sheet1,Sheet1[Category]),Measure 2)) is only summing c1 sum (201810 ,201811).

Please help on this.

 

YearMonthCategoryheadcountExpected Cummulative result  formula its should use
201810C12020201810 +Previous month values starting from Jan 2018
201810C23030201810+Previous month values starting from Jan 2018
201810C34040201810+Previous month values starting from Jan 2018
201810C45050201810+Previous month values starting from Jan 2018
201810C56060201810+Previous month values starting from Jan 2018
201810C67070201810+Previous month values starting from Jan 2018
201811C13050C1 201810 + c1  201811
201811C24070C2 201810 + c2  201811
201811C35090C3 201810 + c3  201811
201811C460110C4 201810 + c4  201811
201811C570130C5 201810 + c5  201811
201811C680150C6 201810 + c6  201811
2 ACCEPTED SOLUTIONS
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

Please refer to below measure:

Measure 4 =
CALCULATE (
    SUM ( Sheet1[headcount] ),
    FILTER (
        ALLEXCEPT ( Sheet1, Sheet1[Category] ),
        Sheet1[YearMonth] <= MAX ( Sheet1[YearMonth] )
    )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Thanks Yuliana for the solution.I also tried Measure 2:=CALCULATE(sumx(FILTER(ALL(Sheet1[YearMonth]),Sheet1[YearMonth]<= max(Sheet1[YearMonth]) ),[Headcountmeasure]),VALUES(Sheet1[Category])) ...its giving the same output.. but i didnt understand how the context is working in this formula.

View solution in original post

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

Please refer to below measure:

Measure 4 =
CALCULATE (
    SUM ( Sheet1[headcount] ),
    FILTER (
        ALLEXCEPT ( Sheet1, Sheet1[Category] ),
        Sheet1[YearMonth] <= MAX ( Sheet1[YearMonth] )
    )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks Yuliana for the solution.I also tried Measure 2:=CALCULATE(sumx(FILTER(ALL(Sheet1[YearMonth]),Sheet1[YearMonth]<= max(Sheet1[YearMonth]) ),[Headcountmeasure]),VALUES(Sheet1[Category])) ...its giving the same output.. but i didnt understand how the context is working in this formula.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.