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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Pony
New Member

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
Solution Supplier
Solution Supplier

Hi @Pony ,

 

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
Solution Supplier
Solution Supplier

Hi @Pony ,

 

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~

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

johnbasha33
Solution Sage
Solution Sage

@Pony 

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 !!

 

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors