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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

How to show previous month when selected month slicer.

I have cumulative measure like this. It cumulative from Oct-Sep in the year

Pony_0-1715329889260.png

I run in to problem when I want select Jan. I want to show value from Out-Jan cumulative on graph

Pony_1-1715329977569.png

The result should be like picture below

Pony_0-1715338511604.png

This is my cumulative measure.
ExpenseYTD =
CALCULATE(
   SUM(Expenses[Expense]),
    FILTER(
        ALL('Date'),
        'Date'[Date] <= MAX('Date'[Date]) &&
        'Date'[FiscalYear] = MAX('Date'[FiscalYear]) &&
        IF(SUM('Expenses'[Expense]) = BLANK(), 0, 1) = 1
    )
)
1 ACCEPTED SOLUTION
xifeng_L
Super User
Super User

Hi @Anonymous ,

 

If your slicer uses the same month as the line chart, pls first change the slicer's month to another month field of other table to avoid the Auto-Exist mechanism.

 

You can copy the date table and name it Date2, without establishing any relationships with other tables. Then, Use the month of Date2 as the field for the slicer.

 

Additionally, based on the line chart you provided, the month field should have a sorting reference field, otherwise the months on the line chart should be out of order.

 

So, we can modify the measure as follows:

 

ExpenseYTD-Modify =
VAR SelectedSlicerMonthIndex = MAX('Date2'[Month Index])
VAR CurLineChartMonthIndex = MAX('Date'[Month Index])
RETURN
IF(CurLineChartMonthIndex <= SelectedSlicerMonthIndex,
    CALCULATE(
       SUM(Expenses[Expense]),
        FILTER(
            ALL('Date'),
            'Date'[Date] <= MAX('Date'[Date]) &&
            'Date'[FiscalYear] = MAX('Date'[FiscalYear]) &&
            IF(SUM('Expenses'[Expense]) = BLANK(), 0, 1) = 1
        )
    )
)

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

View solution in original post

4 REPLIES 4
xifeng_L
Super User
Super User

Hi @Anonymous ,

 

If your slicer uses the same month as the line chart, pls first change the slicer's month to another month field of other table to avoid the Auto-Exist mechanism.

 

You can copy the date table and name it Date2, without establishing any relationships with other tables. Then, Use the month of Date2 as the field for the slicer.

 

Additionally, based on the line chart you provided, the month field should have a sorting reference field, otherwise the months on the line chart should be out of order.

 

So, we can modify the measure as follows:

 

ExpenseYTD-Modify =
VAR SelectedSlicerMonthIndex = MAX('Date2'[Month Index])
VAR CurLineChartMonthIndex = MAX('Date'[Month Index])
RETURN
IF(CurLineChartMonthIndex <= SelectedSlicerMonthIndex,
    CALCULATE(
       SUM(Expenses[Expense]),
        FILTER(
            ALL('Date'),
            'Date'[Date] <= MAX('Date'[Date]) &&
            'Date'[FiscalYear] = MAX('Date'[FiscalYear]) &&
            IF(SUM('Expenses'[Expense]) = BLANK(), 0, 1) = 1
        )
    )
)

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

Anonymous
Not applicable

Thank you so much!!! Your solution is working.

johnbasha33
Super User
Super User

@Anonymous 

To adjust your cumulative measure to show the value for January correctly, you need to modify the filter condition to include the specific month. You can achieve this by adding an additional condition that checks if the month of the date is less than or equal to the selected month. Here's how you can modify your measure:

ExpenseYTD =
CALCULATE(
SUM(Expenses[Expense]),
FILTER(
ALL('Date'),
'Date'[Date] <= MAX('Date'[Date]) &&
'Date'[FiscalYear] = MAX('Date'[FiscalYear]) &&
MONTH('Date'[Date]) = MONTH(MAX('Date'[Date]))
)
)

Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!

 

Anonymous
Not applicable

Sorry If I make you misunderstand. My measure done the cumulative correctly.

The result should like pictuer below if I select only Jan. 

Pony_1-1715338313593.png

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.