Forum Discussion

IF's avatar
IF
Post Prodigy
6 years ago
Solved

previous value

Hi, I have to tables. Table "MonthYear" provides the months at the slicer. "Month" column is text. "Order" column is numeric. The other table is for calculation. I have a slicer for selection of mon...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi IF,

    Yes, it is possible.
    You can extract current date text value and use it to find out the index, then do the calculation to get the previous month index and use it as a condition to filter table records to find out the previous date text.

    BTW, I also modify measure formula to replace allselcted with all function, you can try it if it works:

    Previous result =
    VAR _current =
        SELECTEDVALUE ( Actual[month], MAX ( Actual[month] ) )
    VAR prev =
        FORMAT (
            DATE ( RIGHT ( _current, 4 ), LEFT ( _current, 2 ) - 1, 1 ),
            "mm.yyyy"
        )
    RETURN
        CALCULATE (
            DIVIDE ( SUM ( Actual[Days] ), SUM ( Actual[req] ) ),
            FILTER ( ALL ( Actual ), [month] = prev )
        )
    

    Regards,

    Xiaoxin Sheng