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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
KathleenW
Regular Visitor

How to not have a Rolling 12 be affected by relative date filter?

I have a graph that I want to show the rolling 12 sum of number of sales over the past year.

I want to have it show a years worth of data but I want it to calculate since before the date filter. It WAS working, and looked like this:

KathleenW_0-1709152835530.png

But now when I filter down to Past 365 Days, it looks like this:

KathleenW_1-1709152913287.png

 

It just increases from whenever the start of the graph is rather than calculating from "before" the graph. I have multiple years worth of data before this year. Not sure why it's doing this. The only filter I have on is a Relative date filter.

 

12MonthRolling = CALCULATE (
[Number Sales],
    DATESINPERIOD('Date Table'[Date],LASTDATE('Date Table'[Date]), -365,DAY)
)
1 ACCEPTED SOLUTION
v-jianpeng-msft
Community Support
Community Support

Hi, @KathleenW 

Here's how you calculate your total sales for the past 12 months. I created the following sample data:

vjianpengmsft_0-1709187515147.png

First, I need to generate a continuous date table based on the date column of the sample data, I use the following DAX:

Date = CALENDAR(MIN('Table'[Date]),MAX('Table'[Date]))
Month = MONTH('Date'[Date]) 
Year = YEAR('Date'[Date])

vjianpengmsft_1-1709187799036.png

Next we need to connect this date table with our data table:

vjianpengmsft_2-1709187856281.png

We now begin our rolling sales calculations over the past year. First create a measure to calculate how many months have passed.

Month pass =
COUNTROWS (
    SUMMARIZE (
        CALCULATETABLE (
            'Date',
            DATESBETWEEN (
                'Date'[Date],
                MINX ( ALL ( 'Date'[Date] ), 'Date'[Date] ),
                MAX ( 'Date'[Date] )
            )
        ),
        'Date'[Year],
        'Date'[Month]
    )
)

Calculate rolling sales over the past 12 months via the following DAX:

12MonthRolling =
IF (
    [Month pass] >= 12,
    CALCULATE (
        [Number sales],
        DATESBETWEEN (
            'Date'[Date],
            EDATE ( MIN ( 'Date'[Date] ), -12 ),
            MAX ( 'Date'[Date] )
        )
    ),
    BLANK ()
)

The calculation results are as follows:

vjianpengmsft_3-1709188264909.png

vjianpengmsft_4-1709188345597.png

This will allow you to correctly display cumulative sales starting from the previous data. I have provided the PBIX file used this time below. If it can help you, that would be great. The link below is a case with the same problem as yours.

Solved: Re: Rolling 12 month total - Microsoft Fabric Community

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

1 REPLY 1
v-jianpeng-msft
Community Support
Community Support

Hi, @KathleenW 

Here's how you calculate your total sales for the past 12 months. I created the following sample data:

vjianpengmsft_0-1709187515147.png

First, I need to generate a continuous date table based on the date column of the sample data, I use the following DAX:

Date = CALENDAR(MIN('Table'[Date]),MAX('Table'[Date]))
Month = MONTH('Date'[Date]) 
Year = YEAR('Date'[Date])

vjianpengmsft_1-1709187799036.png

Next we need to connect this date table with our data table:

vjianpengmsft_2-1709187856281.png

We now begin our rolling sales calculations over the past year. First create a measure to calculate how many months have passed.

Month pass =
COUNTROWS (
    SUMMARIZE (
        CALCULATETABLE (
            'Date',
            DATESBETWEEN (
                'Date'[Date],
                MINX ( ALL ( 'Date'[Date] ), 'Date'[Date] ),
                MAX ( 'Date'[Date] )
            )
        ),
        'Date'[Year],
        'Date'[Month]
    )
)

Calculate rolling sales over the past 12 months via the following DAX:

12MonthRolling =
IF (
    [Month pass] >= 12,
    CALCULATE (
        [Number sales],
        DATESBETWEEN (
            'Date'[Date],
            EDATE ( MIN ( 'Date'[Date] ), -12 ),
            MAX ( 'Date'[Date] )
        )
    ),
    BLANK ()
)

The calculation results are as follows:

vjianpengmsft_3-1709188264909.png

vjianpengmsft_4-1709188345597.png

This will allow you to correctly display cumulative sales starting from the previous data. I have provided the PBIX file used this time below. If it can help you, that would be great. The link below is a case with the same problem as yours.

Solved: Re: Rolling 12 month total - Microsoft Fabric Community

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.