Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
shirenmathai
Partner - Contributor III
Partner - Contributor III

Set expression to find common records

Hi All,

Could you please someone help me to correct the set expression. I have two tables, on first table showing the groups and count of users. Second table showing the user details. Users can have multiple groups. If i select multiple groups on first table then users coming in common needs to show on user details table. For example in the attached application if i select group A,B,C then second table should show only the user 1 details, basically filter all sheet objects based on the selected groups in first table with intersect records

Set expression used:-

if(getselectedcount(Group)>0,

count( distinct {<User={"=aggr(count(distinct Group),User)=getselectedcount(Group)"}>} User) ,

count(distinct User)

)

Users:

LOAD  * inline   [

User, Name

1, ABC

2, BCD

3, EFG

4, RTG

5, YUR

6, IOB

7, LIK

];

Matrix:

LOAD  * inline   [

Group,User

A,1

B,1

C,1

B,2

A,2

C,3

D,4

C,5

D,5

E,5

E,5

F,6

G,7

];

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try

...

count( distinct {<User={"=count(distinct Group)=$(=GetSelectedCount(Group))"}>} User)

...

or

count( distinct {<User={"=Count(Distinct Group) = Count(Distinct TOTAL Group)"}>} User)

View solution in original post

8 Replies
dwforest
Specialist II
Specialist II

Set Express is not required.

If tables are left as distinct (not joined ) in load, Qlik will handle the filtering for you (and avoid any fan traps).

the formula should simply be count(DISTINCT User)

swuehl
MVP
MVP

Try

...

count( distinct {<User={"=count(distinct Group)=$(=GetSelectedCount(Group))"}>} User)

...

or

count( distinct {<User={"=Count(Distinct Group) = Count(Distinct TOTAL Group)"}>} User)

dwforest
Specialist II
Specialist II

Ah, missed the needs to be a member of all groups selected part.

Both of Stefan's formula work with your sample data.

shirenmathai
Partner - Contributor III
Partner - Contributor III
Author

Thank you swuehl and dwforest ! for the response. In both the cases, the second user table will show records not part of the current selection. For example if we select Group A,B,C then we have only one user in common that is User 1 but table will show other users as well. Is there any way to avoid these records from User table without adding any extra calculation column.

Please find the screenshot.

Capture.JPG

swuehl
MVP
MVP

Where have you used the set expression? What's your expression?

I would use User as dimension and

=Maxstring( {<User={"=Count(Distinct Group) = Count(Distinct TOTAL Group)"}>} Name)


as expression

dwforest
Specialist II
Specialist II

As Stefan implies, you must have a measure in the table with the set expression to "filter" the records. If you don't want an "extra" column, you can do a Stefan indicates to display the name as your aggregate. Caveat to that is that measures are not filterable, if your selection yields multiple users that you would like to select in the second table as filters, you'd have to have another column; i usually stick them on the right end of the table as a "flag" field.

shirenmathai
Partner - Contributor III
Partner - Contributor III
Author

Thank you

shirenmathai
Partner - Contributor III
Partner - Contributor III
Author

Thank you