Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If statement loop

Hi,

Please assist. I have a table with transaction totals for vendors per period, I need to determine when the last transaction on a vendor took place. Below is an example:

Thus last transaction for vendor 1: Period 3-2015; vendor 2- Period 2-2016

Vendor          Year          Period1          Period2          Period3       

1                   2016             0                     0                    0

1                   2015          100                    0                   50

1                   2014          150                 200                 250

2                   2016             0                 150                     0     

2                   2015          100                100                  100              

2                   2014            50                100                  100

I can determine this via if statement e.g.

if(Period3>0,[Year]& '-' & 3,

if(Period2>0,[Year]& '-' & 2

if(Period1>0,[Year]& '-' & 1,

0))) AS [LAST TRANS]

I am not an experienced QlikView user and I was wondering whether I can't use loops instead (i.e. loop through period columns)  to accomplish this and how I will go about doing this?

Thank you in advance

2 Replies
sunny_talwar

I think you might benefit using CrossTable Load and converting your Period columns into rows. This will help you finding the last transaction date from a single row using Peek/Previous. Check the links out

The Crosstable Load

Qlik Design Blog : Peek() vs Previous() – When ... | Qlik Community

Not applicable
Author

Thank you very much for the response. This will be of great help.