Forum Discussion

jcastr02's avatar
jcastr02
Icon for Post Prodigy rankPost Prodigy
5 years ago
Solved

finding words in a column

I have a column where I want to look for a bunch of key words.  Essentially if the column contains words such as truck OR bus OR car, OR starship, etc.  then I'd like the measure to equal - "Yes"
  • Fowmy's avatar
    5 years ago

    jcastr02 

    Add this as a measure, this is not case-sensitive:



    Found Any Match = IF( NOT( ISEMPTY(INTERSECT({"Bus","Car", "Truck", "StarShip"} , VALUES(Table[ColimnName] )))),"YES","NO")

    ________________________

    If my answer was helpful, please consider Accept it as the solution to help the other members find it

    Click on the Thumbs-Up icon if you like this reply 🙂

    YouTube  LinkedIn

     

     

  • PhilipTreacy's avatar
    5 years ago

    Hi jcastr02 

    This kind of thing is (better?) easier to do in Power Query.  It's not as easy to split text into component words in DAX.

    If you use VALUES('Table'[Column]) you're checking against the entire contents of that row (like saying is a word equal to a sentence?) rather than checking word by word.

    If you first create a calculated column, you can then create a measure from that.

     

    Calculated Column

     

    Match = SWITCH
    (   TRUE(),
    
        SEARCH ( "Bus", ('Table'[Words]), 1, 0 ) > 0, "Yes",
        SEARCH ( "Car", ('Table'[Words]), 1, 0 ) > 0, "Yes",
        SEARCH ( "Truck", ('Table'[Words]), 1, 0 ) > 0, "Yes",
        SEARCH ( "Starship", ('Table'[Words]), 1, 0 ) > 0, "Yes",
        "No"
    )

     

     

    Measure

     

    Found A Match = IF( NOT( ISEMPTY(INTERSECT({"Yes"} , VALUES('Table'[Match] )))),"Yes","No")

     

    Regards

    Phil


    If I answered your question please mark my post as the solution.
    If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.