Forum Discussion

InspiredBI's avatar
InspiredBI
New Member
6 years ago
Solved

Copy columns to a new table using M

Hi All, I am importing a very wide csv ... around 3,000 columns. Using this as a base table, I want to select 100 columns and create a new table using the Table.SelectedColumns function. However, ...
  • edhans's avatar
    6 years ago

    If by base table you mean the query that is importing from the file, and the "already imported table" is a reference to the base table, you cannot tell PQ to just use the smaller 100 column table, because that references the 3,000 column table.

     

    If this were a relational database, Power Query would fold the query back to the server and tell it to only bring back the 100 columns you want. But with any kind of Excel file, text file, SharePoint list, or other non-DB data source, Power Query will always do every step. It doesn't know what 100 columns you want until it brings in the 3,000 first, then it knows which 2,900 to toss.

     

    There is no way around this for text files. Power Query repeats every single step every single refresh.