Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Abdull4h44
Contributor
Contributor

Extracting multiple items from filter to table

Dears,

I am making a table that contain many columns and user can select the columns they are interested in.

I separated the columns in groups, so it is easier to search for items.

The problem happened when selecting multiple items in same filter.

In pictures an example, when I select only one under Figures filter, I will get the column but if both selected, they will be hidden. 

Abdull4h44_0-1714894339886.png

And here after selecting both:

Abdull4h44_1-1714894375870.png

 

I am using this code for each Item in the table (Show column if):

=If(SubStringCount('Gross Premium',GetFieldSelections(_FigureField))>0,1,0)

=If(SubStringCount('Sum Insured',GetFieldSelections(_FigureField))>0,1,0)

 

I Appreciate any suggestions you have and if you have other way or source I can learn from.

Labels (4)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

I was so confused when you reported that my suggestion did not solve your issue, so I had to create a sample app. 

When working on it I realize that we are using SubStringCount() wrongly, the correct syntax is SubStringCount(text, sub_string) and we have used it like this: SubStringCount(sub_stringtext)

 

As you will see in the app, both Concat() and GetFieldSelections () will work (but if you have more than 6 values in _FigureField, then you will have to configure GetFieldSelections() in order to not get the 'All' string) But notice the difference between the two approaches when you have no values selected. (last picture)

 

This  works:

If(SubStringCount(concat(_FigureField,', '),'Sum Insured',)>0,1,0)

If(SubStringCount(concat(_FigureField,', '),'Gross Premium')>0,1,0)

 

Vegar_0-1714930351570.png

Vegar_1-1714930367492.png

Vegar_2-1714930397105.png

 

 

View solution in original post

4 Replies
Vegar
MVP
MVP

The GetFieldSelections will return 'ALL' when all values are selected. None of your substrings are found in the string 'ALL' See https://help.qlik.com/en-US/sense/February2024/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/Field...

Vegar
MVP
MVP

You could try to replace 

GetFieldSelections(_FigureField)

With the following:

Concat(distinct _FigureField, ',')

Abdull4h44
Contributor
Contributor
Author

From my understanding, GetFieldSelections will return values and separated by ","

Concat(distinct _FigureField, ',') will merge the selected with "," , did I get it correctly?

 

I modified the code to the following and it is still the same problem, it returns only one selected item:

=If(SubStringCount('Gross Premium',Concat(distinct _FigureField, ','))>0,1,0)

Same for Sum insured 

Did I do your approach in a wrong way? 

Thanks for your help 

Vegar
MVP
MVP

I was so confused when you reported that my suggestion did not solve your issue, so I had to create a sample app. 

When working on it I realize that we are using SubStringCount() wrongly, the correct syntax is SubStringCount(text, sub_string) and we have used it like this: SubStringCount(sub_stringtext)

 

As you will see in the app, both Concat() and GetFieldSelections () will work (but if you have more than 6 values in _FigureField, then you will have to configure GetFieldSelections() in order to not get the 'All' string) But notice the difference between the two approaches when you have no values selected. (last picture)

 

This  works:

If(SubStringCount(concat(_FigureField,', '),'Sum Insured',)>0,1,0)

If(SubStringCount(concat(_FigureField,', '),'Gross Premium')>0,1,0)

 

Vegar_0-1714930351570.png

Vegar_1-1714930367492.png

Vegar_2-1714930397105.png