Forum Discussion
Using Search in a measure
- 3 years ago
Hi JamesMF1982
If you are creating a measure then you may tryKey Word = IF ( HASONEVALUE ( RESIDENT[AdminType] ), CONCATENATEX ( VALUES ( RESIDENT[AdminType] ), SWITCH ( TRUE (), CONTAINSSTRING ( RESIDENT[AdminType], "Nurse" ), "Nursing", CONTAINSSTRING ( RESIDENT[AdminType], "LA" ), "Local Authority" ) ) )
What would you like the result to be if several words exist? A measure with several full words after each other, like "Nursing Local Authority Benchmark" or something like that?
I think SWITCH() is not perfect in this case since you want to test for each possible word and possibly return several words.
One way (although impractical depending on the number of possible words) would be to do string several either IF(SEARCH()) or maybe even better IF(CONTAINSSTRING()) and test for each word. If the word exists you return the word string, and if not return blank. You would also decide on how to do punctuation/spacing if you have several matches.
result =
if(CONTAINSSTRING(RESIDENT[AdminType],"Nurse"),"Nursing ","") &
if(CONTAINSSTRING(RESIDENT[AdminType],"LA"),"Local authority ","")
And so on. Could work.
Hi, I have tried this but when I use the CONTAINSSTRING option, the column I am trying to reference is not available for selection.
- tamerj13 years agoCommunity Champion
Hi JamesMF1982
If you are creating a measure then you may tryKey Word = IF ( HASONEVALUE ( RESIDENT[AdminType] ), CONCATENATEX ( VALUES ( RESIDENT[AdminType] ), SWITCH ( TRUE (), CONTAINSSTRING ( RESIDENT[AdminType], "Nurse" ), "Nursing", CONTAINSSTRING ( RESIDENT[AdminType], "LA" ), "Local Authority" ) ) )