2
votes

Trying to create a new query from the existing "Master" Query using below formula:

let Source = Table.SelectColumns('Original Source Name',{'Column Name','Column Name2'}) in Source

which works fine, however I am looking to see if there is any other formula which would do the same but in a way that it will create the new query with a range of columns , for example Column 30- 67 ( in this case when the original Excel file is updated, inserting a column in this range it would automatically update in the PBI too when refreshed)

1

1 Answers

3
votes

Here's one possible way. If you start with this table, named Table1:

enter image description here

You can reference it in a new query like this:

let
Source = Table.SelectColumns(Table1, List.Range(Table.ColumnNames(Table1), 2, 3))
in
Source

...to get this:

enter image description here

The formula selects a range of columns from the table starting at the column at index position 2, and spanning 3 columns. (The index starts with 0.) For columns 30-67, you would change the 2 to 31 and the 3 to 37. You would change Table1 to your Original Source Name as well.

See these links for more info on List.Range and Table.ColumnNames.