Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
JamesMF1982
Frequent Visitor

Using Search in a measure

HI all,

 

I'm hoping someone can help me. I have a column (RESIDENT[AdminType]) that has a load of varying data in there which represents a number of settings. For example "NurseLABench" that will mean Nursing,  Local Authority, benchmark or FrailPCTNegot which will mean Frail, PCT and Negotiate

 

What I want to do is search the column and return full words based on found words in the phrase. I can't use a column due to restrictions so have to use a measure.

 

I thought something like SWITCH would work with SEARCH, but I can't get anything to stick.

 

Any help would be amazing.

 

Thanks

1 ACCEPTED SOLUTION

Hi @JamesMF1982 
If you are creating a measure then you may try

Key Word =
IF (
    HASONEVALUE ( RESIDENT[AdminType] ),
    CONCATENATEX (
        VALUES ( RESIDENT[AdminType] ),
        SWITCH (
            TRUE (),
            CONTAINSSTRING ( RESIDENT[AdminType], "Nurse" ), "Nursing",
            CONTAINSSTRING ( RESIDENT[AdminType], "LA" ), "Local Authority"
        )
    )
)

View solution in original post

4 REPLIES 4
TomasAndersson
Solution Sage
Solution Sage

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.

Hi @JamesMF1982 
If you are creating a measure then you may try

Key Word =
IF (
    HASONEVALUE ( RESIDENT[AdminType] ),
    CONCATENATEX (
        VALUES ( RESIDENT[AdminType] ),
        SWITCH (
            TRUE (),
            CONTAINSSTRING ( RESIDENT[AdminType], "Nurse" ), "Nursing",
            CONTAINSSTRING ( RESIDENT[AdminType], "LA" ), "Local Authority"
        )
    )
)
tamerj1
Super User
Super User

Hi @JamesMF1982 

you can use SWITCH along with CONTAINSSTRING 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.