Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Sagwa
Contributor II
Contributor II

if selected values match multiple values

Hello!

Field:

cNameEquipment
11
12

 

Filter: 11, 12

This expresion works only if only one value is selected:

=if( match ( GetFieldSelections (cNameEquipment, ','), '11', '12'), 33, 0)

How should it be for two values selected? Thanks!

Labels (1)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Remember, the answer is almost never "GetFieldSelections()" 😉

When you want to test possible field values against a list, what you want is Max(Match(...))

=if( max(match ( cNameEquipment, '11', '12')), 33, 0)

-Rob

View solution in original post

4 Replies
chrismarlow
Specialist II
Specialist II

Hi,

Two meaning both? How about;

=if( match ( GetFieldSelections (cNameEquipment, ','), '11,12'), 33, 0)

Cheers,

Chris.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Remember, the answer is almost never "GetFieldSelections()" 😉

When you want to test possible field values against a list, what you want is Max(Match(...))

=if( max(match ( cNameEquipment, '11', '12')), 33, 0)

-Rob

Mahilan
Contributor
Contributor

Hi @rwunderlich ,

Solution working for me perfectly. but i want to know the explanation on what max(match()) is  doing here.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

match(x, 'a', 'b', 'c') 

"The match function compares the first parameter with all the following ones and returns the numeric location of the expressions that match"

https://help.qlik.com/en-US/sense/May2023/Subsystems/Hub/Content/Sense_Hub/Scripting/ConditionalFunc...

In the example discussed above, "cNameEquipment" is a field with multiple values. In this case, Match() will return multiple values, some zero and some not. Max() returns the maximum of the returned values, letting us know if at least one value is greater than zero.

-Rob