Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
MindaugasBacius
Partner - Specialist III
Partner - Specialist III

Count

Hei,

I have data like below:

Screenshot_2.jpg

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.

1 Solution

Accepted Solutions
tresesco
MVP
MVP

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;

Capture.PNG

View solution in original post

3 Replies
tresesco
MVP
MVP

Can we generalize it that - the group is Year&Price-based ?

MindaugasBacius
Partner - Specialist III
Partner - Specialist III
Author

Yes.

Also, the script needs to appear in back-end.

tresesco
MVP
MVP

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;

Capture.PNG