Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
Whitney,
Maybe you mean this:
wildmatch(Dimension1, '*A*')
or this:
wildmatch(GetFieldSelections(Dimension1), '*A*')
?
Whitney,
Maybe you mean this:
wildmatch(Dimension1, '*A*')
or this:
wildmatch(GetFieldSelections(Dimension1), '*A*')
?
wildmatch(GetFieldSelections(Dimension1), '*A*') is working exactly as I'd hoped.
Thank you, Michael!
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:
Dimension1 | Dimension1A | Dimension1B | Dimension1C |
A | 1 | 0 | 0 |
B | 0 | 1 | 0 |
C | 0 | 0 | 1 |
Then you can use sum on fields Dimension1A, Dimension1B, or Dimension1C.
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