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
random11
Regular Visitor

Displaying 6 Months back after selecting a month on slicer for a running total

anyone able to help me.

 

for example if i had a sales of £100 per month for 12 months i want this to be cumulative so if i picked on a slicer December it would display £1200 and also the 6 previous months with what there totals would of acumulated in there month so downwards 1200,1100,1000,900 ect.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @random11 

Based on your description, I created the following sample data:

vjianpengmsft_0-1716429067795.png

First, I created the following table using parameters:

vjianpengmsft_1-1716429133582.png

vjianpengmsft_2-1716429167737.png

vjianpengmsft_3-1716429191190.png

Next, I created a measure with the following DAX:

6 Month sales =
VAR _seleted_month =
    SELECTEDVALUE ( 'Month'[Month] )
VAR _number =
    CALCULATE (
        MAX ( 'Month'[Month] ),
        FILTER (
            ALL ( 'Month' ),
            'Month'[Month] = MONTH ( SELECTEDVALUE ( 'Table'[Date] ) )
        )
    )
VAR _past_6_month_sales =
    CALCULATE (
        SUM ( 'Table'[sales] ) * _number,
        FILTER (
            'Table',
            MONTH ( 'Table'[Date] ) <= _seleted_month
                && MONTH ( 'Table'[Date] ) >= _seleted_month - 6
        )
    )
RETURN
    IF (
        ISBLANK ( _seleted_month ),
        SUM ( 'Table'[sales] ) * _number,
        _past_6_month_sales
    )

The table visual is set as follows:

vjianpengmsft_4-1716429305931.png

Here are the results:

vjianpengmsft_5-1716429341968.png

vjianpengmsft_6-1716429352951.png

vjianpengmsft_7-1716429368759.png

When the slicer was not selected, I did a processing and now all the data. When the slicer is selected, the results you expect are displayed. I've provided the PBIX file used this time below.

 

 

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi, @random11 

Based on your description, I created the following sample data:

vjianpengmsft_0-1716429067795.png

First, I created the following table using parameters:

vjianpengmsft_1-1716429133582.png

vjianpengmsft_2-1716429167737.png

vjianpengmsft_3-1716429191190.png

Next, I created a measure with the following DAX:

6 Month sales =
VAR _seleted_month =
    SELECTEDVALUE ( 'Month'[Month] )
VAR _number =
    CALCULATE (
        MAX ( 'Month'[Month] ),
        FILTER (
            ALL ( 'Month' ),
            'Month'[Month] = MONTH ( SELECTEDVALUE ( 'Table'[Date] ) )
        )
    )
VAR _past_6_month_sales =
    CALCULATE (
        SUM ( 'Table'[sales] ) * _number,
        FILTER (
            'Table',
            MONTH ( 'Table'[Date] ) <= _seleted_month
                && MONTH ( 'Table'[Date] ) >= _seleted_month - 6
        )
    )
RETURN
    IF (
        ISBLANK ( _seleted_month ),
        SUM ( 'Table'[sales] ) * _number,
        _past_6_month_sales
    )

The table visual is set as follows:

vjianpengmsft_4-1716429305931.png

Here are the results:

vjianpengmsft_5-1716429341968.png

vjianpengmsft_6-1716429352951.png

vjianpengmsft_7-1716429368759.png

When the slicer was not selected, I did a processing and now all the data. When the slicer is selected, the results you expect are displayed. I've provided the PBIX file used this time below.

 

 

 

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.

 

 

 

aduguid
Super User
Super User

Cumulative Sales Last 6 Months = 
VAR MaxVisibleDate = MAX('Date'[Date])
VAR MinVisibleDate = EDATE(MaxVisibleDate, -6)

RETURN
CALCULATE(
    SUM(Sales[SalesAmount]),
    FILTER(
        ALL('Date'),
        'Date'[Date] <= MaxVisibleDate &&
        'Date'[Date] > MinVisibleDate
    )
)

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.