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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
johnmorgan
Partner - Contributor III
Partner - Contributor III

Aggregate Calculation Based on Value Inclusion in Smaller Set in a Sheet Expression

I am trying to find an expression to aggregate values based on a field in the values existence in another set. 

For example:

  • a user has multiple identifiers
  • I have a table of multiple users
  • I have a table of the identifiers related to my user
  • I have another table of identifiers
  • those identifiers link to ownership of a record. 

I need to count the total distinct records belonging to my current user.  In the same application I need to get aggregates across the rest of the data so I do not want to use a filter or section access to restrict the data.

So basically I am looking  for something that will count distinct based on the intersection of a set with a smaller set.  More succinctly in SQL I would write Select count(distinct record) from record join owners where ownerIdentifier in (list of identifiers)

As example data say I have:

CurrentUserIdentifiers
1111
2222

 

IdentifiersValueDataId 
111112345 
111123456 
222234567 
222245678 
333356789 

 

ValueDataIdD1D2......
12345qwerpoiu  
23456asdfnmhj  
34567zxcvhjkl  
45678bvcxyuio  
56789gfdstrew  

 

And I would like to count the distinct D2 values for the current user in a single expression, without limiting other available data.

Labels (2)
1 Reply
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

If you need just a total for all the CurrentUserIdentifier values, use:

count({<Identifiers=P(CurrentUserIdentifiers)>}DISTINCT D2)

If you need to count perCurrentUserIdentifier I recommend loading "CurrentUserIdentifier as Identifiers"  to create a link. 

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com