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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
lucas_canova
Helper I
Helper I

Cumulative sum by date and category

Hi everyone!

 

I need help. I was trying to perform a dax to return cumulative sum by month and version, in that year. 

example sample:

CATEGORY_1   CATEGORY_2  ...CATEGORY_N  DATE            VERSION   VALUE  CUMULATIVE_SUM
XX X01/01/2023A11
XX X01/01/2023A23
XX X01/01/2023B33
XX X01/01/2023B47
XX X01/02/2023A14
XX X01/02/2023A26
XX X01/02/2023B310
XX X01/02/2023B414
XX X01/01/2024A11
XX X01/01/2024A23
XX X01/01/2024B33
XX X01/01/2024B47
XX X01/02/2024A14
XX X01/02/2024A26
XX X01/02/2024B310
XX X01/02/2024B414
2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

@lucas_canova To get the breakdown that you have in your CUMULATIVE_SUM column you would need an Index which you would then substitute for DATE in this formula:

Cumulative = 
    VAR __Version = [VERSION]
    VAR __Date = [DATE]
    VAR __Table = FILTER( ALL( 'Table' ), [VERSION] = __Version && [DATE] <= __Date )
    VAR __Result = SUMX( __Table, [VALUE] )
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

@Greg_Deckler

thx for reply,

it worked with follow adjusts:

 

 

Cumulative = 
    VAR __Version = SELECTEDVALUE(BASE_TOTAL[VERSAO])
    VAR __Date = SELECTEDVALUE(BASE_TOTAL[SAFRA])
    VAR __Year = YEAR(__Date)
    VAR __Table = FILTER( ALL(BASE_TOTAL), [VERSAO] = __Version && YEAR([SAFRA]) = __Year && [SAFRA] <= __Date )
    VAR __Result = SUMX( __Table, [VALOR] )
RETURN
    __Result

 

Edit:

I ran into a problem working with the previous dax, my slicers werent filtering my cumulative sum chart, so i made a small adjust again:

Cumulative = 
    VAR __Version = SELECTEDVALUE(BASE_TOTAL[VERSAO])
    VAR __Date = SELECTEDVALUE(BASE_TOTAL[SAFRA])
    VAR __Year = YEAR(__Date)
    VAR __Table = CALCULATE( SUM(BASE_TOTAL[VALOR]), FILTER( ALL(BASE_TOTAL), [VERSAO] = __Version && YEAR([SAFRA]) = __Year && [SAFRA] <= __Date ) )
RETURN
    __Table

 

View solution in original post

6 REPLIES 6
lucas_canova
Helper I
Helper I

Hi everyone!

 

I need help. I was trying to perform a dax to return cumulative sum by month and version, in that year. 

example sample:

CATEGORY_1   CATEGORY_2  ...CATEGORY_N  DATE            VERSION   VALUE  CUMULATIVE_SUM
XX X01/01/2023A11
XX X01/01/2023A23
XX X01/01/2023B33
XX X01/01/2023B47
XX X01/02/2023A14
XX X01/02/2023A26
XX X01/02/2023B310
XX X01/02/2023B414
XX X01/01/2024A11
XX X01/01/2024A23
XX X01/01/2024B33
XX X01/01/2024B47
XX X01/02/2024A14
XX X01/02/2024A26
XX X01/02/2024B310
XX X01/02/2024B414
Anonymous
Not applicable

Hi all,

 

I have moved the post under this post, please be aware.

 

Best Regards,

Stephen Tao

@lucas_canova Please don't cross-post: Cumulative sum by date and category - Microsoft Fabric Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

sorry for that.

Greg_Deckler
Community Champion
Community Champion

@lucas_canova To get the breakdown that you have in your CUMULATIVE_SUM column you would need an Index which you would then substitute for DATE in this formula:

Cumulative = 
    VAR __Version = [VERSION]
    VAR __Date = [DATE]
    VAR __Table = FILTER( ALL( 'Table' ), [VERSION] = __Version && [DATE] <= __Date )
    VAR __Result = SUMX( __Table, [VALUE] )
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler

thx for reply,

it worked with follow adjusts:

 

 

Cumulative = 
    VAR __Version = SELECTEDVALUE(BASE_TOTAL[VERSAO])
    VAR __Date = SELECTEDVALUE(BASE_TOTAL[SAFRA])
    VAR __Year = YEAR(__Date)
    VAR __Table = FILTER( ALL(BASE_TOTAL), [VERSAO] = __Version && YEAR([SAFRA]) = __Year && [SAFRA] <= __Date )
    VAR __Result = SUMX( __Table, [VALOR] )
RETURN
    __Result

 

Edit:

I ran into a problem working with the previous dax, my slicers werent filtering my cumulative sum chart, so i made a small adjust again:

Cumulative = 
    VAR __Version = SELECTEDVALUE(BASE_TOTAL[VERSAO])
    VAR __Date = SELECTEDVALUE(BASE_TOTAL[SAFRA])
    VAR __Year = YEAR(__Date)
    VAR __Table = CALCULATE( SUM(BASE_TOTAL[VALOR]), FILTER( ALL(BASE_TOTAL), [VERSAO] = __Version && YEAR([SAFRA]) = __Year && [SAFRA] <= __Date ) )
RETURN
    __Table

 

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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