You can try the following script to flag these fields:
LOAD * INLINE [
UniqueID, Month, Segment
1, 1, A
1, 2, B
2, 1, C
2, 1, C
If(Peek('UniqueID') = UniqueID, If(Peek('Segment') <> Segment, 1, 0)) as Flag
Order By UniqueID;
DROP Table Temp;
Community_163365.qvw 147.8 K
works fine except that the first record in each set of UniqueID do not get a flag status 1 so my list looks like this:
1, 1, A, -
1, 2, B, 1
2, 1, C, -
2, 2, C, 0 (altered Month for last row to be 2 to be more correct)
Could that be fixed still using Peek or do I have to loop through the data with do while or similar?
Massimo, the output I want is:
Currently I do not care about anything but current and previous month so I would not go through more than these months.
But making it more generic I would like to get a Flag (1) for all UniqueID that have different Segment from latest segment.
Taking about result on display I also want to be able to display
UniqueID Month 1 Month 2
1 A B
Filtering on Flag = 1