Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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

Re: If statement loop

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

Re: If statement loop

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

Community Browser