Skip to main content
Announcements
Document boards are being consolidated, this board no longer allows NEW documents READ MORE

Dynamic intersection of sets (Set Analysis)

cancel
Showing results for 
Search instead for 
Did you mean: 
felipedl
Partner - Specialist III
Partner - Specialist III

Dynamic intersection of sets (Set Analysis)

Last Update:

Sep 21, 2022 5:11:51 PM

Updated By:

Sue_Macaluso

Created date:

Oct 20, 2017 9:50:57 AM

Attachments

I've seen quite some times, people asking for intersection for some sort of behaviour that would enable them to make selections and based on them, to see the values (a dimension example could be product type) that are mutual for all the selections made.

As examples, we would have this kind of post in the community:

Set analysis permits this sort of thing, but you would have to explicitly input some dimension value, as in the bellow code

=count (distinct  {<code = P ({<exam={"1"}>} code ) >*<code = P ({<exam={"2"}>} code ) > } code )


to be able to do the intersection.


I've developed an automatic way to do it, simply by building each set and then concatenating them (can be expanded to more variables).

I understand that with each additional set of the selection, it can be quite consuming to make the calculations.

My example is quite simple, so it takes no time at all to compute what I've built.

Selections made on 'Dim2'  field will show the intersected values for 'Dim1'

Example:

Selecting the values 'X' and 'Y' in 'Dim2'  field, should give on the righmost table, the values that are intersected for X and Y, giving the following image:

Sample.png


Hope it helps someone, it was quite fun to try it out.

Update: just added code so that the expression is made automatically.

Felipe.

Tags (1)
Comments
luismadriz
Specialist
Specialist

Hi Felipe, any chance this could be shared for Qlik Sense?

Cheers,

Luis

felipedl
Partner - Specialist III
Partner - Specialist III

Hi luis,

I also added the Sense qvf file in to the post.

Forgot to post some instructions, but the selection for the intersection must be made on the 'Dim2' field, to check which 'Dim1' values have set intersections.

Example:

Selecting the values 'X' and 'Y' in 'Dim2'  field, should give on the righmost table, the values that are intersected for X and Y, giving the following image:

Sample.png

Felipe.

luismadriz
Specialist
Specialist

Legend Felipe,

I'll be studying the work you've done,

Cheers,

Luis

0 Likes
uacg0009
Partner - Specialist
Partner - Specialist

Hi Felip,

I downloaded your qvw file and saw the expression, really cool idea.

But it seems like if there is 5 values in Dim2, then I need to add a x5, am i right? It needs a little hardcode, right?

Thanks.

Aiolos

felipedl
Partner - Specialist III
Partner - Specialist III

Hi Aiolos,

The set analysis expression is based on how many Dim2 fields you have, and so, if you have 10, the expression is created to get all 10.

As an example, I've put 5 and 6 fields on Dim2, with the following result for the expression:

Dim2: 5 fields

sample1.png

Dim2: 6 fields

sample2.png

So, as you can see, if I add a new Dim2 value, it should get more expressions out of the constructed set analysis.

Felipe. !

uacg0009
Partner - Specialist
Partner - Specialist

Hi Felipe,

Really thanks for you explanation, I got it!

Thanks.

Aiolos

Version history
Last update:
‎2022-09-21 05:11 PM
Updated by: