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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Filter rolling sum by status in current month

Hi all,

 

I have a table as shown below with many more materials, and a rolling sum measure for each material that usually works just fine.

MATERIALDateSTD_MARGINLEM_STATUS
A31171931.03.20220Yellow
A31171928.02.20220Yellow
A31171931.01.20220Yellow
A31171931.12.20210Yellow
A31171930.11.20210Yellow
A31171931.10.20210Red
A31171930.09.202122,37Red
A31171931.08.20210Yellow
A31171931.07.20210Yellow
A31171930.06.20210Yellow
A31171931.05.202114,39Yellow
A31171930.04.2021-0,33Yellow

I'd like to filter by the status of the current month --> only data with e.g. status =yellow in current month is displayed, but the rolling sum should still take all past 12 months into account, no matter what status they had.

As of right now, I simply put the status in a slicer on my report page, but because the entire table is filtered by the status, the rolling sum value is incorrect.

For example for March and Status = Red --> 22,37 is displayed , however I'd want to have 22,37+14,39-0,33 =36,43. 

For March and Status =yellow 14,39-0,33=14,06 is calculated, but I'd also want 22,37+14,39-0,33 =36,43 as calculation.

So what I'm looking for is not exactly a filter for the entire table, but rather for the current month status , without messing up the rolling sum calculation.

 

Any help would be much appreciated!

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

You need a separate date table to provide parameters for your formula.

And please try this formula to do it.

 

Measure =
VAR _end =
    MAX ( 'Date'[Date] )
VAR _start =
    DATE ( YEAR ( _end ) - 1, MONTH ( _end ), DAY ( _end ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[STD_MARGIN] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[MATERIAL] ),
            'Table'[Date] >= _start
                && 'Table'[Date] <= _end
        )
    )

 

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

3 REPLIES 3
Anonymous
Not applicable

Nevermind, I got it working, thanks for the help!! 

Anonymous
Not applicable

Hi @v-chenwuz-msft,

 

thanks for yor response, that measure seems to work, the Status is now excluded from the calculation.

The calculation is correct, but I would still need to filter by the status in the current month while still maintaining the correct sums over the last 12 months. So if i selected yellow, all last twelve months are calculated, independently of the status in each month, but only the current month=yellow Materials would show. As of right now, the status filter is excluded for the calculation, which is correct, but also for the filtering in the current month.
Would I need a seperate table with the status for this?

v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

You need a separate date table to provide parameters for your formula.

And please try this formula to do it.

 

Measure =
VAR _end =
    MAX ( 'Date'[Date] )
VAR _start =
    DATE ( YEAR ( _end ) - 1, MONTH ( _end ), DAY ( _end ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[STD_MARGIN] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[MATERIAL] ),
            'Table'[Date] >= _start
                && 'Table'[Date] <= _end
        )
    )

 

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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