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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
SharkeyNZ
Contributor
Contributor

Nested Aggr help in Measure

I'm trying to create measures (within Sheets - I don't have access to Load editor or the data model) to count, average, find max and min number of requests that a manager's team has (ultimately to go in a box plot).  The basic unit to count is a [Request ID], complicated by multiple rows for each [Request ID] across the fields I'm interested in.

Example: (There are other fields in the data set that result in what appear to be duplicate records/rows).

Record ID[Request ID][Worker ID][Manager ID]
1RI001WI001MI001
2RI001WI001MI001
3RI001WI002MI002
4RI002WI001MI001
5RI002WI003   MI001
6RI003WI003 MI001
7RI004WI004MI002

I only want to count a [Request ID] once in the calculation and I'm fine with taking the first or last [Worker ID]  (alphabetically), and excluding the others.  eg my results Tables would look like this:

[Manager ID]Count Record ID included in Calculation 
MI00131 or 2,  4, 6
MI00217

or

[Worker ID]CountRecord ID included in Calculation
WI00121 or 2, 4
WI0020 
WI00316
WI00417

 

I thought there might be a way to use the Aggr function to do this.  In SQL I'd probably partition by [Request ID], sorting by [Worker ID], then select the first record in the partition, and count  group by [Worker ID] or [Manager ID] (there is probably a better way).  I'm  not  sure how to do this in Qlik Sense.

 

Labels (1)
1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Use these as your measures:

  • count(distinct [Request ID])
  • concat([Record ID], ',')

talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Use these as your measures:

  • count(distinct [Request ID])
  • concat([Record ID], ',')

talk is cheap, supply exceeds demand
SharkeyNZ
Contributor
Contributor
Author

Thanks.  That works