Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Show previous month values based on slic

Hi there,   I use the following measure to summarize the revenue for the current month: CurrentMonthRevenue = CALCULATE(SUM(Order[Revenue]), FILTER(Order, MONTH(Order[Date])=MONTH(TODAY()))   ...
  • v-yanjiang-msft's avatar
    3 years ago

    Hi Anonymous ,

    According to your description, it's because in the formula you provided, havn't take the Date slicer into consideration. Here's my solution.

    Order table:

    Date table:

    Create two measures.

    CurrentMonthRevenue =
    CALCULATE (
        SUM ( 'Order'[Revenue] ),
        FILTER (
            'Order',
            MONTH ( 'Order'[Date] )
                = IF (
                    ISFILTERED ( 'Date'[Month] ),
                    SELECTEDVALUE ( 'Date'[Month] ),
                    MONTH ( TODAY () )
                )
        )
    )
    
    PreviousMonthRevenue =
    VAR current_month =
        IF (
            ISFILTERED ( 'Date'[Month] ),
            SELECTEDVALUE ( 'Date'[Month] ),
            MONTH ( TODAY () )
        )
    RETURN
        CALCULATE (
            SUM ( 'Order'[Revenue] ),
            FILTER ( 'Order', MONTH ( 'Order'[Date] ) = current_month - 1 )
        )
    

    Result:
    If there isn't month been selected in the slicer, it will return the current month and corresponding previous month.

    If other month is selected in the slicer, it will return the selected month and corresponding previous month.

    I attach my sample below for your reference.

     

    Best Regards,
    Community Support Team _ kalyj

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