Forum Discussion

Sir_night's avatar
Sir_night
Frequent Visitor
9 years ago
Solved

Previous Record

With help from dearwatson i was able to identify the status changes between records  https://community.powerbi.com/t5/Desktop/Combining-Dynamic-Query-Parameters-and-Append-Queries/m-p/206856#M91132 ...
  • GilbertQ's avatar
    9 years ago

    Hi Sir_night

     

    You could create the following measure as long as you have got a Date table, which is required for the measure below.

     

    To create a Date table you can follow this blog post: https://www.fourmoo.com/2016/09/13/power-bi-how-to-easily-create-dynamic-date-tabledimension-with-fiscal-attributes-using-power-query/

     

    And then once that is done you can then create the following measure.

     

    Measure Yesterday Rolling = 
    CALCULATE (
        [Measure Name],
        LASTNONBLANK ( DATEADD ( 'Date'[Date], -1, DAY ), [Measure Name] )
    )
  • v-sihou-msft's avatar
    9 years ago

    Sir_night

     

    In your scenario, since you already have an index column, if you want to calculate previous record, you can create a calculated column with EARLIER to get the corresponding one:

     

    previous record =
    CALCULATE (
        MAX ( Table[status change] ),
        FILTER ( Table, Table[index] = EARLIER ( Table[Index] ) - 1 )
    )

    However, based on your data, it seems your "prevouse record" shows the next "status change", so your column might be:

     

     

    =
    CALCULATE (
        MAX ( Table[status change] ),
        FILTER ( Table, Table[index] = EARLIER ( Table[Index] ) + 1 )
    )

    Regards,