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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Multiple if - OR - If and Contains Statement Help Please

Hello,

Fairly new to Power BI so excuse any lack in terminology or decorum.

I have a data set that has a column where the values contain (example) ...."-WP"....

I created a new column named contains WP and put the following as the function...

 

= If(ISERROR(SEARCH("-WP",'TABLE_NAME'[COLUMN_IN_TABLE])),"No","Yes")

This worked like a charm for what I was trying to do.

 

 
I am now trying to do something very similar but now I need to say if contains ..."-D01"... or ..."-D02"... all the way out to ..."-D17"...
Trying to figure out a multiple If contains statement but am having a hard time getting it right.
 
Anyone have any suggestions?
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Just to wrap this up and call this solved, here is what I did...

 

= CONTAINSSTRING('MY_TABLE'[MY_COLUMN],"AK??-D*")

 

This gave me the True/False values I needed in the new column. 

View solution in original post

3 REPLIES 3
Nathaniel_C
Community Champion
Community Champion

Hi @Anonymous ,

Try SWITCH(
          TRUE(),
          [MyMeasure]<1,expr1,
          [MyMeasure]<2,expr2,
          [MyMeasure]<3,expr3,
         …)
Works great for a lot of values such as you have, or you can make a {list} and use IN ---'Product'[Color] IN { "Red", "Blue", "Black" }

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Nathaniel,

Thanks for the help but I am afraid I am going to need a little extra. I have not worked with SWITCH function very much and am sorry to say I am not grasping it.

 

Here is an example of what I tried to do to solve my problem, unfortunately it did not work... 

= If(Or(Left('MY_TABLE'[MY_COLUMN],6)="AK31-D",TRUE()),
If(Or(Left('MY_TABLE'[MY_COLUMN],6)="AK32-D",TRUE()),
If(Left('MY_TABLE'[MY_COLUMN],6)="AK33-D",TRUE(),FALSE())))

 

An example of the data in the column would be "AK31-D01-*****-****"

I need to be able to apply a return value of either Yes/No or TRUE/FALSE if anywhere in the string exists -D01 or D-02 or D-03 etc... up to and including -D17.

 

I feel like I somewhat understand the concept of SWITCH but, I am not quite understanding the <1 <2 etc part of it.

Anonymous
Not applicable

Just to wrap this up and call this solved, here is what I did...

 

= CONTAINSSTRING('MY_TABLE'[MY_COLUMN],"AK??-D*")

 

This gave me the True/False values I needed in the new column. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.