Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikplaut
Partner - Contributor III
Partner - Contributor III

Comparing values in the same table

Hello,

I'm struck and I need your advice.

yearCustomerIDProductIDflag
2012b001a001lost
2012b002a002
2012b003a003
2012b004a004lost
2013b002a002renew
2013b005a001new
2013b006a003new
2013b003a003renew

I have a table with year, customerID and productID and I want to create a column named flag (preferably in the load script). I would also be satisfied with creating 3 columns (lost,renew,new), but I don't know exactly how to do this with values from the same table.

renew= customerID&productID exist in 2013 and also in 2012.

lost = customerID&productID exist in 2012 but not in 2013

new = customerID&productID exist in 2013 but not in 2012

How can I compare the values? My guess would be to use one of the functions: exists, lookup or peek.

Thank you in advance.

1 Solution

Accepted Solutions
Gysbert_Wassenaar

See attached example.


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar

See attached example.


talk is cheap, supply exceeds demand
RedSky001
Partner - Creator III
Partner - Creator III

Here is another approach, although Gysbert Wassenaar method is much cleaner.

qlikplaut
Partner - Contributor III
Partner - Contributor III
Author

Gysbert, Mark

Thank you very much for your help. I managed to make it work using Gysbert's method, however I also like what Mark did. I always liked that QV lets you do something in more than one way.

Thanks again guys!