Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Search column names for multiple criteria

Hi, 

Am fairly new to Power BI and currently working to solve columns that changed names. I got a bit of help from vids online but encountered a road block. 

I want to look for the words "EAST_" or "EASTON_"  from the  table column names . So , i got to this part:

= List.Select (Table.ColumnNames(Base), each Text.Contains(_,"EAST_"))

How do I add another criteria to this line such that it also searches for the word "EASTON_" so that i can call on all the colums with the said names and change them on subsequent steps after wards

2 Replies

  • Vijay_A_Verma's avatar
    Vijay_A_Verma
    Most Valuable Professional

    Use this

    = List.Select(Table.ColumnNames(Base), (x)=> List.AnyTrue(List.Transform({"EAST_", "EASTON_"}, (y)=> Text.Contains(x,y))))
  • You can use the following format with the List.Contains function: 

     

    = List.Select( Table.ColumnNames( Custom1 ), each List.Contains( { "EAST_", "EASTON_"}, _ ) )

     

    It checks whether the list of columnnames contains any of the values in the first argument of List.Contains (https://powerquery.how/list-contains/

     

    Regards,

    Rick de Groot

    --------------------------------------------------

    @ me in replies or I'll lose your thread

     

    Master Power Query M? -> https://powerquery.how

    Read in-depth articles? -> BI Gorilla

    Youtube Channel: BI Gorilla

     

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