Forum Discussion
DAX returning 2 values when only 1 is selected
- 1 year ago
This is the solution that finally worked -
RQDel =SWITCH(TRUE(),CONTAINSSTRING('Pipeline'[Delegated Services], "Pre-Risk") && CONTAINSSTRING('Pipeline'[Delegated Services], ", Risk") && CONTAINSSTRING('Pipeline'[Delegated Services], ", Quality"), "PR, R, Q",CONTAINSSTRING('Pipeline'[Delegated Services], "Pre-Risk") && CONTAINSSTRING('Pipeline'[Delegated Services], ", Quality"), "PR, Q",CONTAINSSTRING('Pipeline'[Delegated Services], "Pre-Risk") && CONTAINSSTRING('Pipeline'[Delegated Services], ", Risk"), "PR, R",CONTAINSSTRING('Pipeline'[Delegated Services], "Risk") && CONTAINSSTRING('Pipeline'[Delegated Services], ", Quality"), "R, Q",CONTAINSSTRING('Pipeline'[Delegated Services], "Pre-Risk"), "PR",CONTAINSSTRING('Pipeline'[Delegated Services], "Risk"), "R",CONTAINSSTRING('Pipeline'[Delegated Services], "Quality"), "Q","")
Hi LYBridges
Make sure to include a space before and after Risk so it becomes " Risk "
RQDel =
CONCATENATEX (
FILTER (
ADDCOLUMNS (
{ ( 1, "Pre-Risk", "PR" ), ( 2, " Risk ", "R" ), ( 3, "Quality", "Q" ) },
"@Result", IF ( CONTAINSSTRING ( Pipeline[Ops Delegated Services], [Value2] ), [Value3] )
),
NOT ISBLANK ( [@Result] )
),
[@Result],
",",
[Value1], ASC
)
Thanks for a new take on this!
I tried it out and these are the results based on what is currently in the data source.
Correct returned values -
If the source column has Pre-Risk, it correctly returns PR.
Incorrect returned vaules -
If the source coulmn has all 3, it returns only PR,Q.
If the source column has Pre-Risk and Risk, it returns only PR
If the source column has Risk and Quality, it returns only Q.
If the source column has Risk, it returns a blank.
I have a multi-select/mulit-choice column that can have any combination of 18 different choices.
For the new column/DAX I'm trying to create, we are only interested in the choices Pre-Risk, Risk and/or Quality.
For each row, we want to know which one or which combination of choices were selected. Due to limited space, we are trimming down to just abbreviations (PR, R, Q).
So the new column will have one or any combination of PR, R, Q displayed based on the multi-select column in the source.
- tamerj11 year ago
Community Champion
Depending on how Risk is written in the source. It might be " Risk" or " Risk,". This is something you can find out by looking at some values of the source column.
- LYBridges1 year agoFrequent Visitor
It shows up as " Risk,".
I'll try that.
Thanks so much. Love the approach.