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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
rx98u5pq
Contributor III
Contributor III

top N by 2 dimensions table chart

Hi, this should be relatively straight forward and I have tried 3 approaches without it working:

I want the top 5 rows (not dimensions values) by #users in a straight table.
When i limit it by dimension I get the top 5 dimensions values which can mean more than 5 rows:
If i try a measure it does not work using aggregation:

#Users = count(distinct USER_ID)

AVG TIME = sum(TOTAL TIME] / count(distinct USER_ID)

am i missing something when i try the following?

=SUM(aggr(if(rank(count(distinct USER_ID))<= 5, count(distinct USER_ID)), [EVENT ID], ACTION))

I only want the green rows to show.  As you can see event id is not unique and neither is Action

rx98u5pq_0-1744014310633.png

 



Labels (2)
1 Solution

Accepted Solutions
rx98u5pq
Contributor III
Contributor III
Author

Hi, thanks for the response but using the dimension filter for both dimensions does not work.  it still bring back the top 5 dimension values, which is not the top 5 rows, e.g. there could be two rows for A here when you use the filter.
this measure ended up working:

 

 

If(
    Aggr(
        Rank(
            {<Event_ID = {"*"}>}[# Users],
            1, 1
        ),
        Event_ID
    ) <= 5,
    [# Users]
)



View solution in original post

3 Replies
sk88024
Creator
Creator

Because in your data, Event ID = A and Action = 1 are present in two places,

So, in Qlik, the table will look like this. This is not something which can controlled using any sum, aggr or count function. 

sk88024_1-1744019323922.png

 

Also, to show top N only, you can use the limitation option for both dimensions. 

sk88024_2-1744019462995.png

Then, the table will look like this - 

sk88024_3-1744019526886.png

rx98u5pq
Contributor III
Contributor III
Author

Hi, thanks for the response but using the dimension filter for both dimensions does not work.  it still bring back the top 5 dimension values, which is not the top 5 rows, e.g. there could be two rows for A here when you use the filter.
this measure ended up working:

 

 

If(
    Aggr(
        Rank(
            {<Event_ID = {"*"}>}[# Users],
            1, 1
        ),
        Event_ID
    ) <= 5,
    [# Users]
)



marcus_sommer

If you didn't want to aggregate the data on Event and Action you will need to add a further appropriate information to differentiate between the n records.