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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount 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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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