Forum Discussion

julie_tai's avatar
julie_tai
Frequent Visitor
7 years ago
Solved

Create a dynamic reference line for tracking 12 months

As a beginner, I searched lots of articles, and it worked out with showing the visual data for tracking 12 months. Now there is another problem, which is, I would like to use the last-month average ...
  • v-cherch-msft's avatar
    v-cherch-msft
    7 years ago

    Hi ryan_mayu

     

    Try below measure:

    Measure = 
    VAR CurrentDate =
        MAX ( 'Date-2'[Date] )
    VAR PreviousDate =
        DATE ( YEAR ( CurrentDate ), MONTH ( CurrentDate ) - 11, 1 )
    RETURN
        IF (
            MAX ( 'Date'[Date] ) >= PreviousDate
                && MAX ( 'Date'[Date] ) <= CurrentDate,
            CALCULATE (
                [Demand Charge per Train] + [Energy Charge per Train],
                FILTER ( ALLSELECTED ( 'Date' ), 'Date'[Date] = CurrentDate )
            )
        )
    

    Regards,

    Cherie