Forum Discussion

SSRk's avatar
SSRk
Frequent Visitor
6 months ago
Solved

Sorting X- axis based on Month-Year slicer selection

Hi Team, I am facing a chellenge to sort x-axis based on selection of filter. Image-1 Here L12M Amount is the last 12 months data from selected month. PL12M Amount is the previous last 12...
  • johnt75's avatar
    johnt75
    6 months ago

    You can use

    PL12M Amount =
    VAR MaxDate =
        MAX ( 'Date'[Date] )
    VAR StartDate =
        EOMONTH ( MaxDate, -12 ) + 1
    VAR MaxDupeDate =
        MAX ( 'Dupe Date'[Date] )
    VAR Result =
        IF (
            MaxDupeDate >= StartDate && MaxDupeDate <= MaxDate,
            VAR Result =
                CALCULATE (
                    SUM ( Sheet1[consum] ),
                    SAMEPERIODLASTYEAR ( 'Dupe Date'[Date] ),
                    REMOVEFILTERS ( 'Date' ),
                    USERELATIONSHIP ( 'Date'[Date], 'Dupe Date'[Date] )
                )
            RETURN
                Result
        )
    RETURN
        Result
    

    I tried this in a dummy model and it worked.