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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
RobMorris
Frequent Visitor

Formula for multiple "LIKE" statements in DAX?

I'm new to PowerBI having moved over from SAP Crystal Reports and one of the issues I'm having is replacing the custom formulas I had created previously.

 

We have a table that shows the type of streetlights that are used within the Borough and in Crystal I had the following formula set up:

If {LAMPS.LAMPDESC1} like "*LED*" then "LED" else

If {LAMPS.LAMPDESC1} like "*SON*" then "High Pressure Sodium - SON" else
If {LAMPS.LAMPDESC1} like "*High Pressure Sodium*" then "High Pressure Sodium - SON" else

If {LAMPS.LAMPDESC1} like "*SOX*" then "Low Pressure Sodium - SOX" else
If {LAMPS.LAMPDESC1} like "*Low Pressure Sodium*" then "Low Pressure Sodium - SOX" else

If {LAMPS.LAMPDESC1} like "*CPO*" then "Cosmopolis" else
If {LAMPS.LAMPDESC1} like "*Cosmopolis*" then "Cosmopolis" else

If {LAMPS.LAMPDESC1} like "*Electronic Ballast*" then "Electronic Ballast" else

If {LAMPS.LAMPDESC1} like "*High Pressure Mercury*" then "High Pressure Mercury" else

If {LAMPS.LAMPDESC1} like "*Low Pressure Mercury*" then "Low Pressure Mercury" else

If isnull ({LAMPS.LAMPDESC1}) then "No data" else

"Others"

 

Trying to set this up in PowerBI has got my completely confused.  I have found help on here for if I want to search for 2 types of values using the following formula

Column =

IF (

SEARCH ( "SON*", LAMPS[LAMPDESC1],, 0 ) = 0,

IF ( SEARCH ( "LED*", LAMPS[LAMPDESC1],, 0 ) = 0, "Others", "LED Lights" ),

"SON Lights"

)

but how do I expand that out to include MULTIPLE searchs as per the previous formula I was using?

 

Any help would be very gratefully received!!!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

This should work:

 

Column =
    SWITCH(TRUE(),
        SEARCH("LED", LAMPS[LAMPDESC1], 1, 0) > 0, "LED",
        SEARCH("SON", LAMPS[LAMPDESC1], 1, 0) > 0, "High Pressure Sodium - SON",
        .
        .
        .
        ISBLANK(LAMPS[LAMPDESC1]), "No data",
        "Others"
    )

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

This should work:

 

Column =
    SWITCH(TRUE(),
        SEARCH("LED", LAMPS[LAMPDESC1], 1, 0) > 0, "LED",
        SEARCH("SON", LAMPS[LAMPDESC1], 1, 0) > 0, "High Pressure Sodium - SON",
        .
        .
        .
        ISBLANK(LAMPS[LAMPDESC1]), "No data",
        "Others"
    )

Column =

SWITCH(TRUE(),

SEARCH("LED", LAMPS[LAMPDESC1], 1, 0) > 0, "LED",

SEARCH("SON", LAMPS[LAMPDESC1], 1, 0) > 0, "High Pressure Sodium - SON",

SEARCH("*High Pressure Sodium*", LAMPS[LAMPDESC1], 1, 0) > 0, "High Pressure Sodium - SON",

SEARCH("*SOX*", LAMPS[LAMPDESC1], 1, 0) > 0, "High Pressure Sodium - SON",

SEARCH("*Low Pressure Sodium*", LAMPS[LAMPDESC1], 1, 0) > 0, "Low Pressure Sodium - SOX",

SEARCH("*CPO*", LAMPS[LAMPDESC1], 1, 0) > 0, "Cosmopolis",

SEARCH("*Cosmopolis*", LAMPS[LAMPDESC1], 1, 0) > 0, "Cosmopolis",

SEARCH("*Electronic Ballast*", LAMPS[LAMPDESC1], 1, 0) > 0, "Electronic Ballast",

SEARCH("*High Pressure Mercury*", LAMPS[LAMPDESC1], 1, 0) > 0, "High Pressure Mercury",

SEARCH("*Low Pressure Mercury*", LAMPS[LAMPDESC1], 1, 0) > 0, "Low Pressure Mercury",

ISBLANK(LAMPS[LAMPDESC1]), "No data",

"Others"

)

 

 

Brilliant - this has worked perfectly!  Thanks for your help.

Anonymous
Not applicable

Thanks a lot

 

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors