Forum Discussion

mike87's avatar
mike87
Frequent Visitor
8 years ago
Solved

Calculating changes on daily data

Hi,    I am trying to create a measure that calculates the daily change for a stock price. I have tried to use LASTDATE function, but for some wierd reason, it turns out December 31th 2017 instead ...
  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    8 years ago

    Hi mike87

     

    Try this MEASURE.
    File attached here as well

    PriceChange =
    VAR LastPirce =
        CALCULATE (
            VALUES ( Table1[Stock Price] ),
            FILTER ( Table1, Table1[Date] = MAX ( Table1[Date] ) )
        )
    VAR SecondLastDate =
        CALCULATE (
            MAX ( Table1[Date] ),
            FILTER ( Table1, Table1[Date] < MAX ( Table1[Date] ) )
        )
    RETURN
        LastPirce
            - CALCULATE ( VALUES ( Table1[Stock Price] ), Table1[Date] = SecondLastDate )