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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
bigman24
Frequent Visitor

SEARCH Function with IF Statement

I am trying to flag a list of item in a Product Name column using the SEARCH function.  I have tried using both an IF Statement as well as a SWITCH function.  Essentially I am wanting to flag in a calculated column if a product meets the criteria and then I will use that 1,0 flag in future calculations.  Can someone help me with the following formulas?

 

=If(
SEARCH("*Gift Card*", 'Product'[ProductName])
|| SEARCH("*Play*", 'Product'[ProductName])
|| SEARCH("*Rental*", 'Product'[ProductName])
|| SEARCH("*Refund*",'Product'[ProductName])
|| SEARCH("*Service Fee*", 'Product'[ProductName])
|| SEARCH("*Prior Day*", 'Product'[ProductName])
|| SEARCH("*Activation*", 'Product'[ProductName])
|| SEARCH("*Award*", 'Product'[ProductName])
|| SEARCH("*Booking*", 'Product'[ProductName])
|| SEARCH("*Ticektless*", 'Product'[ProductName])
|| SEARCH("*Lanyard*", 'Product'[ProductName]), 1,0)

 

This is the switch funtion I tried using:

 

= SWITCH(

                True(),

                                SEARCH("*Gift Card*", 'Product'[ProductName],,1)

                                ,SEARCH("*Play*", 'Product'[ProductName],,1)

                                ,SEARCH("*Rental*",'Product'[ProductName],,1)

                                ,SEARCH("*Refund*", 'Product'[ProductName],,1)

                                ,SEARCH("*Service Fee*", 'Product'[ProductName],,1)

                                ,SEARCH("*Prior Day*", 'Product'[ProductName],,1)

                                ,SEARCH("*Activation*", 'Product'[ProductName],,1)

                                ,SEARCH("*Award*",'Product'[ProductName],,1)

                                ,SEARCH("*Booking*",'Product'[ProductName],,1)

                                ,SEARCH("*Ticketless*", 'Product'[ProductName],,1), BLANK())

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@bigman24 try this

 

=If(
SEARCH("*Gift Card*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Play*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Rental*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Refund*",'Product'[ProductName],,-1)>=0
|| SEARCH("*Service Fee*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Prior Day*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Activation*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Award*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Booking*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Ticektless*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Lanyard*", 'Product'[ProductName],,-1)>=0
, 1,0)

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

2 REPLIES 2
parry2k
Super User
Super User

@bigman24 try this

 

=If(
SEARCH("*Gift Card*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Play*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Rental*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Refund*",'Product'[ProductName],,-1)>=0
|| SEARCH("*Service Fee*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Prior Day*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Activation*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Award*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Booking*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Ticektless*", 'Product'[ProductName],,-1)>=0
|| SEARCH("*Lanyard*", 'Product'[ProductName],,-1)>=0
, 1,0)

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

That seems to have worked!  Thank you very much.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors