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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Calculating the cumulative sum of values for Each month

i have a table with two columns "Month", and Count. i want to create a third column that has the value for the cumulative sum of Count value plus the of the previous months.

 

The syntax below is not correct which is what i'm struggling with the most, but i'm hoping it helps explain what intend to do. there could be smarter ways to do this which is what i'm hoping for

Trends := 
VAR cumsum= 0
RETURN SWITCH(table,
             "January",  VAR jansum = countValue + cumsum
               cumsum= jansum
            RETURN cumsum,

              "February", VAR febsum = countValue + cumsum
               cumsum=febsum
             RETURN cumsum)

 

any ideas would be grand. Thanks

2 REPLIES 2
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Did you solve it? Can you share the answer or mark the proper answer as a solution please?

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

What does your data look like? Maybe you can try the formula below.

 

Column =
CALCULATE (
    SUM ( 'Table2'[count] ),
    FILTER (
        'Table2',
        'Table2'[StartOfMonth] <= EARLIER ( 'Table2'[StartOfMonth] )
    )
)

Capture2.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards,

Dale

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors