Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Zeta
Contributor III
Contributor III

Monitor the length of a variable table

Hi all,

Let a table with x entries be given.
The table responds to all filters.
Depending on the filter operation, the table changes its length.
No matter which filters are used, it should always be displayed how many rows the table consists of when using the set filters.

What is the best way to monitor the number of rows in a table?

Would you include this measure in the table or use a separate chart?
If you included this metric in the table, how would you code it?

I thought of adding this measure to the table and defining each row with a fixed "1". Then use the 'Totals function' "Sum" on this column. But maybe someone has a smarter solution.

Thanks in advance.

Labels (3)
1 Solution

Accepted Solutions
Or
MVP
MVP

There's no specific way to do this - it depends on the actual table and the desired layout and appearance. Adding a measure with '1' that gets summed into a total is one way to go about it. You can also count the distinct values for the combination of table dimensions, excluding any combination for which all measures are 0 or null (depending on whether zero/null values are displayed) and display that in the table title, in a different object, etc. Finally, you can enable chart-level scripting and use that to count the rows, placing the value into a separate row, which is similar to the Totals approach but less intrusive. That said, I would likely not use the last approach unless it was the only option available, but sometimes it might be...

View solution in original post

2 Replies
Or
MVP
MVP

There's no specific way to do this - it depends on the actual table and the desired layout and appearance. Adding a measure with '1' that gets summed into a total is one way to go about it. You can also count the distinct values for the combination of table dimensions, excluding any combination for which all measures are 0 or null (depending on whether zero/null values are displayed) and display that in the table title, in a different object, etc. Finally, you can enable chart-level scripting and use that to count the rows, placing the value into a separate row, which is similar to the Totals approach but less intrusive. That said, I would likely not use the last approach unless it was the only option available, but sometimes it might be...

AustinSpivey
Partner - Creator
Partner - Creator

I think that @Or has the correct solution here with the suggestion to use =1 in a measure field and then set the Totals option to Sum. However if you ever need to show the table count in the chart title or in a separate object like a KPI, you could use the Aggr() function to count records for the same dimension groupings as your table object.

=Sum(Aggr(1, [Alpha], "=Upper(Dim1)"))

This expression emulates a table that has the dimension [Alpha] and a field-on-the-fly dimension =Upper(Dim1).  The Sum() function here simply counts the 1 value for the grouping of those two dimensions.

Note that this option is fine if you have a table without too many records and dimensions but it can get slow and finicky if you have lots of rows and/or dimensions because Qlik is essentially calculating this table twice instead of just once.

This GIF shows that expression being used in the title of a table chart:

Screen recording of Qlik Sense table row count expressionScreen recording of Qlik Sense table row count expression

Austin Spivey | Principal Consultant @ Arc Analytics
ArcAnalytics.us | Add me on LinkedIn