Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Query Filter: Column A or Column B contains specific text

Hi,

 

I wish to filter Column A or Column B whichever contains the word "Bio" in query.

How can I do that?

 

  • Hi Anonymous ,

    By power query, you can use Text.Contains() function like this and filter it as TRUE().

    = Table.AddColumn(#"Changed Type", "Custom",  each Text.Contains([ColumnA],"Bio") or Text.Contains([ColumnB],"Bio") )

    By Dax, you can create this measure, put it in the visual filter and set its value as 1:

    Measure = 
    IF(
        CONTAINSSTRING(SELECTEDVALUE('Table'[ColumnA]),"Bio") ||
        CONTAINSSTRING(SELECTEDVALUE('Table'[ColumnB]),"Bio"),
        1,0
    )

    Attached a sample file in the below, hopes to help you.

     

    Best Regards,
    Yingjie Li

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

2 Replies

  • Anonymous , You can use them in a measure like this

     

    calculate([measure], filter( Table, search("Bio",[column1],,0)>0 || search("Bio",[column2],,0) >0))

  • v-yingjl's avatar
    v-yingjl
    Community Support

    Hi Anonymous ,

    By power query, you can use Text.Contains() function like this and filter it as TRUE().

    = Table.AddColumn(#"Changed Type", "Custom",  each Text.Contains([ColumnA],"Bio") or Text.Contains([ColumnB],"Bio") )

    By Dax, you can create this measure, put it in the visual filter and set its value as 1:

    Measure = 
    IF(
        CONTAINSSTRING(SELECTEDVALUE('Table'[ColumnA]),"Bio") ||
        CONTAINSSTRING(SELECTEDVALUE('Table'[ColumnB]),"Bio"),
        1,0
    )

    Attached a sample file in the below, hopes to help you.

     

    Best Regards,
    Yingjie Li

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