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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
knut12212
Helper I
Helper I

cumulative sum of the past months

Current Measure:

Running total in Monate =

CALCULATE(

    SUM('Salesdata'[Sales]),

    FILTER(

        ALLSELECTED('Salesdata'[Months]),

        ISONORAFTER('Salesdata'[Months], MAX('Salesdata'[Months]), DESC)

    )

)

 

How can I extend the formula so that only the cumulative sum of the past months is displayed? In the column Number of Past Periods the maximum value indicates how many periods have already passed. So if the value in the column Months is greater than the maximum value in the column Number of Past Periods, then the running total for that month should return 0.

 

I tried to do it with ChatGPT, but I couldn’t come up with a reliable solution, which is why I would appreciate any tips or a suggested solution.

1 ACCEPTED SOLUTION

Hi @knut12212,

Could you please describe the issue you're experiencing in detail? Also, kindly share the sample PBIX file along with the expected output so we can help resolve the problem.

 

Thank you.

View solution in original post

6 REPLIES 6
v-saisrao-msft
Community Support
Community Support

Hi @knut12212,

Checking in to see if your issue has been resolved. let us know if you still need any assistance.

 

Thank you.

v-saisrao-msft
Community Support
Community Support

Hi @knut12212,

Have you had a chance to review the solution we shared earlier? If the issue persists, feel free to reply so we can help further.

 

Thank you.

I could not find a suitable solution. However, as the dashboard was due to last Friday, I did not change that

Hi @knut12212,

Could you please describe the issue you're experiencing in detail? Also, kindly share the sample PBIX file along with the expected output so we can help resolve the problem.

 

Thank you.

govind_021
Super User
Super User

Hi @knut12212 
Please Try This

Running Total Past Months =
VAR MaxPastPeriods =
MAX ( 'Salesdata'[Number of Past Periods] )
VAR CurrentMonth =
MAX ( 'Salesdata'[Months] )
RETURN
IF (
CurrentMonth <= MaxPastPeriods,
CALCULATE (
SUM ( 'Salesdata'[Sales] ),
FILTER (
ALLSELECTED ( 'Salesdata'[Months] ),
ISONORAFTER ( 'Salesdata'[Months], CurrentMonth, DESC )
)
),
0
)

Best Regards
Govind Sapkade ( Microsoft Certified Data Analyst , PL 300 Certified , MS Fabric Enthusiast)
Let's Connect
Linkdin - www.linkedin.com/in/govind-sapkade-845104225
Youtube - http://www.youtube.com/@govind_dataanalyst

v-saisrao-msft
Community Support
Community Support

Hi @knut12212,

I reproduced your issue with sample data and was able to create the issue in Power BI. I've attached the PBIX file for your reference.

Running Total with Past Periods Limit = 
VAR CurrentMonth = MAX('Salesdata'[Months])
VAR MaxPastPeriods = MAX('Salesdata'[Number of Past Periods])
RETURN
CALCULATE(
    SUM('Salesdata'[Sales]),
    FILTER(
        ALLSELECTED('Salesdata'),
        'Salesdata'[Months] <= CurrentMonth &&
        'Salesdata'[Months] >= CurrentMonth - MaxPastPeriods + 1
    )
)

vsaisraomsft_0-1757938240565.png

 

Hope this helps

Thank you.

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.