Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Previous Row Value in Calculated Column, not Measure

Hi,    I'm simply trying to reference a previous row using a calculated column rather than a measure. I've seen a lot of solutions using measures, but not many using columns (and the column solutio...
  • jdbuchanan71's avatar
    jdbuchanan71
    7 years ago

    Anonymous 

    Perfect, thank you for the sample file.  We just need to incorporate the WELL_NAME into our calculation.

    Calculated Column = 
    VAR CurrentRow = 'ANADARKO_MV'[DAY_DATE]
    VAR CurrentWell = ANADARKO_MV[WELL_NAME]
    VAR PreviousDate =
        CALCULATE (
            MAX ( 'ANADARKO_MV'[DAY_DATE] ),
            FILTER ( ALL ( 'ANADARKO_MV' ), 'ANADARKO_MV'[DAY_DATE] < CurrentRow && ANADARKO_MV[WELL_NAME] = CurrentWell)
        )
    RETURN
        CALCULATE (
            SELECTEDVALUE( 'ANADARKO_MV'[OIL_AP_DISP_CAT] ),
            FILTER ( ALL ( 'ANADARKO_MV' ), 'ANADARKO_MV'[DAY_DATE] = PreviousDate && ANADARKO_MV[WELL_NAME] = CurrentWell)
        )