Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

QV11 Conditional Expressions - includes instead of equals

Hi,

I'd like to use conditional logic to make an expression visible if the selection on Dimension1 includes value A. That is, visible if only A is selected, or A and B, or A B and C, etc.

So instead of [Dimension1]='A' I was thinking something ilke [Dimension1]+='A', but that seems to cause the expression to be visible at all times, regardless of if A is part of the selection.

Appreciate any guidance!

Whitney

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Whitney,

Maybe you mean this:

wildmatch(Dimension1, '*A*')

or this:

wildmatch(GetFieldSelections(Dimension1), '*A*')

?

View solution in original post

4 Replies
Anonymous
Not applicable
Author

Whitney,

Maybe you mean this:

wildmatch(Dimension1, '*A*')

or this:

wildmatch(GetFieldSelections(Dimension1), '*A*')

?

Not applicable
Author

wildmatch(GetFieldSelections(Dimension1), '*A*') is working exactly as I'd hoped.

Thank you, Michael!

Not applicable
Author

Be aware that GetFieldSelections returns a string and wildmatch does a string comparison. This means that if you have a value that is a substring of another then both will be select (e.g. if smiles and mile are options and the user selects mile then both expressions will return true). Also, GetFieldSelections has a max number of values before it returns 'x of y values'.

An alternative is to use set analysis such as: Only({$<Dimension1*={'A'}>} Dimension1)='A'. This usually works if there are only a few conditionals. If there are too many conditionals then the calculation for the conditionals can a lot of time.

If the dimension is a known size and does not have too many values then you can create individual fields for each dimension value. The field value will be 1 if it corresponds to the dimension value, 0 if not. So the table will looks something like this:

Dimension1Dimension1ADimension1BDimension1C
A100
B010
C001

Then you can use sum on fields Dimension1A, Dimension1B, or Dimension1C.

Anonymous
Not applicable
Author

That's correct, GetFieldSelections function has its nuances.  Speaking of limited number of selected values - this one is easy to overcome:

GetFieldSelections(FieldName, ',',10000)

gives you 10,000 values before saying "10,001 of 1,000,000"

The "smiles and mile" issue is more annoying, but looks like it is not relevant in this specific situation.

Anyway, thank you for the comment and the alternative.

Regards,

Michael