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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Finding substring with multiple values

Similar problems have been answered before but the solutions are not quite working in my case. I'm relatively new to DAX, so not sure if this is easily solvable.

 

My main data source is quite large, but essentially looks like the below: 

abagnasco_7-1633109062544.png

 

My objective is to search the highlighted "Ingredient" column for a list of substrings (example below), therefore flagging anything that has the word "tea","milk", or "strawberry"

abagnasco_8-1633109078827.png

 

The challenge: the table 2 contains 100+ ingredients to find, so using a variable or formula is not feasible. 

 

Is there a way to search a column for a larger list of substrings?

 

Hoping to get this output:

abagnasco_9-1633109229417.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Please use the following DAX formula to create a calculated column:

Column =IF(
      SUMX(MatchList,
           FIND(
                UPPER(MatchList[Keyword]),
                UPPER(Companies[Company])
                ,,0
               )
          ) > 0,
      “YES!”,
      “Probably Not”
     )

Eyelyn9_0-1633488939222.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous ,

 

Please use the following DAX formula to create a calculated column:

Column =IF(
      SUMX(MatchList,
           FIND(
                UPPER(MatchList[Keyword]),
                UPPER(Companies[Company])
                ,,0
               )
          ) > 0,
      “YES!”,
      “Probably Not”
     )

Eyelyn9_0-1633488939222.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

KNP
Super User
Super User

Do you have the complete list of words somewhere?

I'd be referencing that and using a PowerQuery formula to flag the rows.

That way you have a dynamic solution simple by adding new values to the list.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!

Yes! This would be the way to go for long term solution, especially if that list changes. All you'd need to do is update that list somewhere (e.g. Excel in SharePoint...), bring that list into PQ, and reference it in a PQ formula similar to the IN operator in DAX.

itsme
Resolver I
Resolver I

You can create a Flag column by doing something like this:

Flag =

SWITCH (
    TRUE (),
    CONTAINSSTRING ( 'Table'[Ingredient], "tea" )"Flag",
    CONTAINSSTRING ( 'Table'[Ingredient], "milk" ), "Flag",
    BLANK ()
)

Anonymous
Not applicable

thank you! 
I was thinking about doing an additional column like that but am trying to avoid entering the words to search manually, since there are 100+ of them in the actual dataset. is there a way to automate the creation of that formula though with the larger list of words to search for? 

If the strings of words you are searching for covers the entire value (like if you search for "milk" it will not pick up "whole milk", only "milk"), then you can use the IN operator and you can just list out the values, e.g. ...'Table'[Ingredient] IN { "milk", "tea", "whole milk" }... But you'd still have to enter them manually.

 

In the solution I gave earlier, if you have the list of words you want to filter, you can paste them into Excel and use formulas to create an entire DAX statement and then copy/paste it into Power BI. 

itsme_0-1633117323149.pngitsme_1-1633117335268.pngitsme_2-1633117349975.png

Still take some time but not nearly as long as typing everything down. You can do a lot of copy/paste/dragging to duplicate values in Excel.

Helpful resources

Announcements
December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.