Forum Discussion

Blackworms's avatar
Blackworms
Frequent Visitor
9 years ago
Solved

Individual Visual Filtering & MoM Comparison

Hi everyone,   First of, thanks for all the help on the forums; however, I have a problem which I couldn't resolve at all since I am kind of beginner with DAX.   My dataset has unique Sales Year-...
  • v-huizhn-msft's avatar
    9 years ago

    Hi Blackworms,

    You should calculate this year sales use DATESMTD function.

    This Year Sales = CALCULATE(SUM([SalesRevenue]);DATESMTD('Calendar'[Date].[Date]))


    As I tested, I create a relationship between Calendar and Sales table, and create two measure usingthe following formulas, it works fine.

    This Year Sales = TOTALMTD(SUM(Sales[SALE]),'Calendar'[DATE])

     

    Last Year Sales = 
    VAR DataMaxDate =
        CALCULATE ( MAX('Calendar'[Date] ), ALL ('Calendar'[Date]) )
    RETURN
        CALCULATE (
            [This Year Sales],
    			SAMEPERIODLASTYEAR (
                INTERSECT (
                    VALUES ( 'Calendar'[Date]),
                    DATESBETWEEN ( 'Calendar'[Date],BLANK (), DataMaxDate )
                )
            )
        )

     

    Please see the following screenshot, when I select particular month, it still shows correctly.



    Thanks,
    Angelia