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: 
hopkinsc
Partner - Specialist III
Partner - Specialist III

Counting the rows in a table and assigning the number to a new field

Hi everyone,

I am trying to create a new field in Qlik to be able to use it in the page node of NPrinting so it will split a table into multiple pages if the table is too big for a single page. 

So i have a table of commentary in Qlik which is by month/year/sheet. For every month/year/sheet i want to count the number of rows, then if there are 4 or less, assign the number 1 to a new field, if it has 6 rows, then the first 4 i want to assign the number 1 and the next 2 i want to assign the number 2 etc.

Can anyone help please?

I have attached a sample 

Labels (2)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I suggest:

Ceil(AutoNumber(RecNo(), Key) / 4)

Specifically, in your sample:

NoConcatenate
Data:
LOAD
  *,
  Ceil(AutoNumber(RecNo(), Key) / 4) as NewField
;
Load *,
  Year&'-'&Month&'-'&Sheet as Key
Resident DataINLINE; 

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

View solution in original post

2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I suggest:

Ceil(AutoNumber(RecNo(), Key) / 4)

Specifically, in your sample:

NoConcatenate
Data:
LOAD
  *,
  Ceil(AutoNumber(RecNo(), Key) / 4) as NewField
;
Load *,
  Year&'-'&Month&'-'&Sheet as Key
Resident DataINLINE; 

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Thats great, thanks very much Rob!