I have this parameter Year in Power Query. Its value is 2024, however I would like to change it eventually, but withou open Power Query. I would like to change it directly on a cell in an Excel sheet. Is it possible?
Already tried referencing the parameter to the cell.
2
Yes, you can control Parameters in Power Query via cells in excel if you set them up properly. It depends as to what you’re trying to do more specifically, but for the sake of documentations I’ll show how to filter using a single input.
I have a query “_Years”. And first what I do is I create a table with the year as the only value in the table. I do this by highlighting the header and 2024 cell and hitting CTRL
+ T
and in the “Table Design” tab of the ribbon I changed the table name to “_Filter”.
Then, under the “Data” tab, while I have the table selected I choose “From Table/Range”.
This will open the Power Query window on the single table. Right-click the cell value and select “DrillDown”
Then what I’ll do just to get the syntax in power query is I’ll apply the logic manually to the table, so I will select the column I’m filtering and select a value.
Then, I change the 2024 in the formula bar to be the “_Filter”. Then you can Close & Load. You can change the = operator to be greater than, lesser than, etc. Users can update that cell in the spreadsheet and refresh the query and it will apply the new value as a filter.
After all is said and done, you can delete the tabs for the queries you don’t need. For example, you don’t need the query for the filter table being pushed to the tab, so deleting this tab will keep the query but skip the effort of loading it to a sheet.
You could create a name for cell for ‘Year’ parameter, for example forYear
and then in Advanced Editor:
let
Source = yours,
Year = Excel.CurrentWorkbook(){[Name = "forYear"]}[Content]{0}[Column1],
filteredRows = Table.SelectRows(Source, each [Year] = Year)
in
filteredRows
Then, (as VBasic2008 also mentioned in comments), you could change the parameter Excel and refresh to get the updated results.