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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors