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
byte007
New Member

Wildcard in search function

Hi all,

 

I'm trying to figure out how to use the wildcard within my search code as I don't want to repeat the code over and over so if I have Oranges it will put it in the Oranges catagory but if there is Oranges - big, Oranges - small I want it to appear in the same line as below and I've tried adding * after "Oranges*" but it has no desired change and still only groups Oranges.

 

SearchFeature = SWITCH (
    TRUE (),
              	SEARCH ( "Oranges", 'Query1'[Column],, 0 ) = 1, "Oranges",
"Others")

 

Thanks in advance for any pointers 🙂 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@byte007 , I think it should be like

SearchFeature = SWITCH (
TRUE (),
SEARCH ( "Oranges", 'Query1'[Column],, 0 ) > 0, "Oranges",
"Others")

 

Search return position

View solution in original post

5 REPLIES 5
FrankAT
Community Champion
Community Champion

Hi @byte007 

you can use wildcards '*' and '?' in SEARCH() function, but as @amitchandak mentioned there is no need for your example.

Take a look at: https://docs.microsoft.com/en-us/dax/search-function-dax

 

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

Greg_Deckler
Super User
Super User

@byte007 - I am not aware of any wildcard matching in SEARCH of FIND or CONTAINSSTRING. Should be able to use CONTAINSSTRING I think.

I usually use something like:

 

SearchFeature = 
  SWITCH (
    TRUE (),
    SEARCH ( "Oranges", 'Query1'[Column],, 0 ) > 0, "Oranges", "Others"
  )

 

I did invent a Fuzzy string matching algorithm just recently though!

https://community.powerbi.com/t5/Quick-Measures-Gallery/Fuzzy/td-p/1352914


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@byte007 , I think it should be like

SearchFeature = SWITCH (
TRUE (),
SEARCH ( "Oranges", 'Query1'[Column],, 0 ) > 0, "Oranges",
"Others")

 

Search return position

Thanks all for the super pointers 🙂

 

I tried @amitchandak change and this worked a treat for me as I now see the results as expected including adding a ? for the wildcard, this picks up the other oranges big small etc

SearchFeature = SWITCH (
TRUE (),
SEARCH ( "Oranges?", 'Query1'[Column],, 0 ) > 0, "Oranges",
"Others")

 

appreciate the fast replies 🙂

Icey
Community Support
Community Support

Hi @byte007 ,

 

Glad to hear that. Please accept your solution above so that people who may have the same question can get the solution directly. Your contribution is highly appreciated.

 

 

Best Regards,

Icey

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.