Forum Discussion

abadi_89's avatar
abadi_89
Frequent Visitor
5 years ago
Solved

Last 2 months difference measure

Hello all, This is driving me crazy, I tried alot of stuff but it looks I can't do it.   I have this table: CS Code CS Name Date Value CS01 Ketchup 1/6/2020 0.946375 CS01 Ketchup ...
  • FrankAT's avatar
    5 years ago

    Hi abadi_89 

    you can di it like this:

     

     

    Measure = 
    VAR _MaxDate = MAX('Table'[Date])
    VAR _PreviousDate = CALCULATE(MAX('Table'[Date]),'Table'[Date] < _MaxDate)
    VAR _ValueOfMaxDate = CALCULATE(MAX('Table'[Value]),FILTER('Table',_MaxDate = 'Table'[Date]))
    VAR _ValueOfPreviousDate = CALCULATE(MAX('Table'[Value]),FILTER('Table',_PreviousDate = 'Table'[Date]))
    RETURN
        _ValueOfMaxDate - _ValueOfPreviousDate

     

    With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
    FrankAT (Proud to be a Datanaut)