Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Numbering Rows more examples?

Hi there,

I was just reading a post this evening and i wanted to solve it, but i couldnt cause i do not have much experience within this and i think its hard to find good examples.

IS there anyone with solid experience in when to use what when you want to number rows? I read HIC blog about Counters but its more explaination than examples.

Let me show some examples i would like to be able to solve:

CustomerDateAmountHowToGetThis?
102-01-2013501
102-01-2013502
203-01-2013201
303-01-2013341
403-01-2013121
404-01-2013232
404-01-2013243
504-01-2013241
CustomerDateAmountHowToGetThis?
102-01-2013501
102-01-2013501
203-01-2013202
303-01-2013343
403-01-2013124
404-01-2013234
404-01-2013244
504-01-2013245
CustomerDateAmountHowToGetThis?
102-01-2013501
102-01-2013501
203-01-2013203
303-01-2013344
403-01-2013125
404-01-2013235
404-01-2013245
504-01-2013248

If it possible??

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III


An unoptimized example model will make things much clearer!

Happy code-cracking.

Peter

View solution in original post

3 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Yes, that's possible. This may not be the best solution but it works.

When loading your ordered table (first Customer, then Date) use the previous() function to check the last record read and compare the Customer numbers. If they are equal, define [HowToGetHis?] with a value of the previous [HowToGetThis?] + 1, otherwise its value will be one.

Something like:

LOAD Customer, Date, Amount,

     if (previous(Customer) = Customer, previous([HowToGetThis?])+1, 1) AS [HowToGetThis?]

FROM/RESIDENT/WHATEVER

The second example isn't entirely clear to me... Are you duplicating the Customer Nr? Or do you want to continue counting whenever the Customer number changes? In the latter case, use the first example but substitute previous([HowToGetThis?]), previous([HowToGetThis?])+1 for the True/False clauses.

For the third example you'll need the RowNo() value that is used whenever the Customer number changes. For all other rows with an identical Customer number, use previous() again.

I don't have a QlikView version handy right now, so I'm unable to provide you with a model. Sorry.

Good luck,

Peter

Peter_Cammaert
Partner - Champion III
Partner - Champion III


An unoptimized example model will make things much clearer!

Happy code-cracking.

Peter

Not applicable
Author

Fantastic - Thanks for taking your time.

Happy christmas