none
How to pass a list of column names to Table.SelectColumns? RRS feed

  • Question

  • Greetings, 
    Let's say I have a variable named TableAColumnNames that is a list of column names from TableA. How would I pass each value in TableAColumnNames to Table.SelectColumns so that I can select matching columns from TableB?

    Thanks for your help!


    • Edited by deguzdude Monday, December 19, 2016 11:06 PM
    Monday, December 19, 2016 11:06 PM

Answers

  • Greetings, 
    Let's say I have a variable named TableAColumnNames that is a list of column names from TableA. How would I pass each value in TableAColumnNames to Table.SelectColumns so that I can select matching columns from TableB?

    Thanks for your help!


    If that's exactly what you want to do (select columns in TableB based on matching column names in TableA then the step is simply:

    SelectedColumns = Table.SelectColumns(TableB, TableAColumnNames)

    • Marked as answer by deguzdude Tuesday, December 20, 2016 4:45 PM
    Tuesday, December 20, 2016 2:12 AM

All replies

  • I would convert the list into a table, then use the UI to create a join, then look at the generated code

    Self Service BI Expert using Power Pivot http://exceleratorbi.com.au

    Tuesday, December 20, 2016 1:26 AM
  • Greetings, 
    Let's say I have a variable named TableAColumnNames that is a list of column names from TableA. How would I pass each value in TableAColumnNames to Table.SelectColumns so that I can select matching columns from TableB?

    Thanks for your help!


    If that's exactly what you want to do (select columns in TableB based on matching column names in TableA then the step is simply:

    SelectedColumns = Table.SelectColumns(TableB, TableAColumnNames)

    • Marked as answer by deguzdude Tuesday, December 20, 2016 4:45 PM
    Tuesday, December 20, 2016 2:12 AM
  • OH. MY. GOD. I didn't know I could pass the list as a variable. Too easy. Thanks so much for your help!
    Tuesday, December 20, 2016 4:47 PM
  • Thanks Matt. I'm going to go with Colin's super simple solution. I didn't know I could pass the list as variable name to the Table.SelectColumns function. 
    Tuesday, December 20, 2016 4:59 PM