Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

SEARCH Function To Flag Products

I am trying to do a calculated column with using a search function.  I have tried using two different methods and I get errors with each.  Essentially I am trying to find test in the Product Name column and assin it a 1 to later filter out the 1's for a listing prodcuts I want to include in a calculation.  Here are the two ways I went about doing it:

 

=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]), 1,0)

 

And this way I thought I was getting fancy:

 

= 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())

2 Replies

  • v-piga-msft's avatar
    v-piga-msft
    Icon for Resident Rockstar rankResident Rockstar

    Hi Anonymous ,

    It seems that there is no syntax error for both of the formulas.

    What error message do you get?

    If it is convenient, could you share your data sample which could reproduce your scenario and your desired output so that we could help further on it.

    Best Regards,

    Cherry

     

  • v-piga-msft's avatar
    v-piga-msft
    Icon for Resident Rockstar rankResident Rockstar

    Hi Anonymous ,

    Have you solved your problem?

    If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

    If you still need help, please share your data sample and your desired output so that I could have a  test on it.

    Best Regards,

    Cherry