Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
michaelfentondata
Partner - Contributor III
Partner - Contributor III

Count number of rows in an expression label of a Straight Table

Is it possible to return the number of rows in my table as part of my expression label?

My table has conditional dimensions, so depending on what the user selects, it may display aggregate values or transaction level values.  I would like my label to display "Avg Rent / Week" if the value is an aggregate, or just "Rent / Week" if the user has selected transaction level details.

I can determine if it is at the transaction level by comparing the count of rows in the table with Sum(PropertyCount).  If the count of rows is less than Sum(PropertyCount), I will display "Avg Rent / Week", if the count of rows = Sum(PropertyCount), I will display "Rent / Week".

I have tried NoOfRows(), but it always returns 1.

If this does not work, an alternative may be to have two expressions (eg. Avg and Sum) and let the user choose which one to display.

20 Replies
Not applicable

Hi

select the component,open properties and in windows title use this

='String'& Count(fieldname)

sujeetsingh
Master III
Master III

just use the count(Dimension You are using)

Not applicable

Have you tried using NoOfRows(Total) ?


I know this will work in the body of a chart - but will return '1' if used in the title.

michaelfentondata
Partner - Contributor III
Partner - Contributor III
Author

sujeet and Vishwanatha,

As I described in my initial post, I am using a set of conditional dimensions.  The user could display any combination they want to, so those counts will not work.  I am trying to compare the count of rows in the table to count of unique records in the fact table.

michaelfentondata
Partner - Contributor III
Partner - Contributor III
Author

tresesco and Clark,

I have tried all combinations of RowNo() and NoOfRows() with and without TOTAL.  The expression label appears to behave the same way as the chart title, and returns 1 in all situations.

Not applicable

Michael - can you post a sample QVW so we could see why it isn't working?

I have used NoOfRows(Total) in my apps many times for this result.

PrashantSangle

Hi,

Please find enclosed file,

It is showing total nos of rows as per your requirements

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
michaelfentondata
Partner - Contributor III
Partner - Contributor III
Author

Hi Max,

You are displaying the NoOfRows in the expression, not the expression header.

tresesco
MVP
MVP

Well, if you want that in the header, you have to use aggr() like:

=Aggr(NoOfRows(Total),YourDimension)

See the attached sample, I have modified the max dreamer's sample file.

Note: In this case it is equivalent to =Count( Distinct YourDimension)         // when single dimension is used in the chart

michaelfentondata
Partner - Contributor III
Partner - Contributor III
Author

The dimensions are conditional.  You cannot know at design time which ones the user is going to select.

That is the reason for the original requirement.