Search code examples
excelexcel-formulaexcel-365xlookupindex-match

How do you flag cells by comparing values in another column with the same 'ID' column?


I have a sample table like this:

base

1

I wanted to flag if there is an increase in Output of the same ID compared to the previous Date. Note that the data is only sorted by Date.

Expected output: output

2

I've been trying to find the correct formula so that it only compares between current output with previous output of the same ID in previous date with INDEX-MATCH functions and had no luck. Thank you for your assistance.

=IF(AND(D2>INDEX($D$2:$D$9, MATCH(C2,$C$2:$C$9,0)-1), C2=INDEX($C$2:$C$9, MATCH(B2,$B$2:$B$9,0)-1)), "Flag", "")

Solution

  • Try the following formula-

    =IF(C2>TAKE(TAKE(FILTER($C$2:$C2,$B$2:$B2=B2,0),-2),1),"Flag","")
    

    enter image description here