Forum Discussion

charcoal's avatar
charcoal
Regular Visitor
2 years ago
Solved

Retrieving value from earlier row with multiple filters

Major novice here, trying to retrieve usage values from a previous date of the same Product/Color/Machine to use to calculate change from previous day. Trying to highlight any major change from previ...
  • danextian's avatar
    danextian
    2 years ago

    Please try this:

     

    Last Val = 
    VAR LastStartTime =
        CALCULATE (
            MAX ( 'Table'[Start Time] ),
            FILTER (
                ALLEXCEPT ( 'Table', 'Table'[Product], 'Table'[Color], 'Table'[Machine] ),
                'Table'[Start Time] < EARLIER ( 'Table'[Start Time] )
            )
        )
    RETURN
        CALCULATE (
            MAX ( 'Table'[Usage] ),
            FILTER (
                ALLEXCEPT ( 'Table', 'Table'[Product], 'Table'[Color], 'Table'[Machine] ),
                'Table'[Start Time] = LastStartTime
            )
        )