Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hei,
I have data like below:
I need to create a Group field. The logic is that the Group depends on the order of the Year.
For example Price 2 appears in two intervals 2000-2001 and 2005-2006. That's two different groups.
I have attached the example file.
May be like:
tmp:
LOAD * INLINE
[ Year, Price
2000, 2
2001, 2
2002, 4
2003, 4
2004, 3
2005, 2
2006, 2
]
;
NoConcatenate
tmp2:
LOAD *,
if(Price=Peek('Price'), peek('Group'), RangeSum(Peek('Group'),1)) as Group
Resident tmp
Order By Year;
DROP Table tmp;
Can we generalize it that - the group is Year&Price-based ?
Yes.
Also, the script needs to appear in back-end.
May be like:
tmp:
LOAD * INLINE
[ Year, Price
2000, 2
2001, 2
2002, 4
2003, 4
2004, 3
2005, 2
2006, 2
]
;
NoConcatenate
tmp2:
LOAD *,
if(Price=Peek('Price'), peek('Group'), RangeSum(Peek('Group'),1)) as Group
Resident tmp
Order By Year;
DROP Table tmp;