Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
Gartner® Magic Quadrant™: 15 YEARS A LEADER - GET THE REPORT
cancel
Showing results for 
Search instead for 
Did you mean: 
peter_turner
Partner - Specialist
Partner - Specialist

How to get a simple count of rows in a table

Hello Everyone,

I'm trying to find a simple way to make my table title show the number of rows in the current selection.

Usually I just count one of my ID fields such as count(MY_ID), but I'm looking if there is a built in function I can use instead?
Similar to the "Sum of Rows" feature for an expression, just need a simple count of the number of rows that are shown on screen.

Does QV have a built in function for this sort of thing or anyone have any ideas?
The dataset is large with 6million+rows.


Thanks,
Peter.



OSZAR »
34 Replies
Durgadevikumar
Partner - Contributor III
Partner - Contributor III

Hi peter,

Let a= Noofrows(tablename) is simply provides the count of rows in a table.

Regards,

DurgadeviKumar

Jude2
Contributor
Contributor

Same, has anyone found an answer for this?

chrissurguine
Contributor II
Contributor II

1. Create a runtime variable called vRowCounter, with a definition of =RowNo(TOTAL)

2. Add a new expression to your table with definition of =Sum($(vRowCounter))

3. Under Styling, make sure you have Totals turned on to either Position Top or Bottom, whichever you prefer.

4. If you want to hide the 1's, set the Text Color expression to White().

5. If you also want to hide the header, set the definition to =' ' (i.e. a space)

seanbruton
Luminary Alumni
Luminary Alumni

Hi Peter,

Try this solution, I hope it helps you.

I have also experienced the same issues you are having in the past. It becomes problematic when your ID field which you are counting on is also a key field in the data model.

So what I found that works well is to add a field eg; 1 as ind1  to the table. Then sum this field or count if you wish. 

 

Regards

Sean

peter_turner
Partner - Specialist
Partner - Specialist
Author

Hello all!

I wanted to close this post down, as lots has changed in the 15 years since I posted it.

There have been lots of great replies and suggestions, so your answer will depend on your specific app. These days i generally would suggust to use flags in the data model such as value 1, which you can count/sum or use in set analysis etc etc, lots of other community posts on the advantages of this.

Also, add steps into the data loading script to clean/model the data, so your UI dashboard can show actionable information, and not simply a replacement for excel.

OSZAR »