Thursday, June 23, 2016

Power BI - Edit query to add back a column

In building reports and queries, it is good practice to select only the columns you need. Power BI makes this easy, but what if you now need a column you originally omitted?  Or, to remove unwanted columns. They both follow the same approach.

With Power BI, all you need to do is use the query editor.

Overview


  1. Start the Query Editor
  2. Select your query (typically a table)
  3. Edit the Column List using the Choose Columns pop-up - two approaches:
    1. Manage Columns button
    2. Applied Steps listing
      1. Locate the Applied Step where the columns were filtered out
      2. Click on the 'Gear' for Applied Step where you removed the columns
  4. In the Choose Columns pop-up, select the new column(s)
  5. Click 'OK'

That's it.


The Details


To get started, on the main page, start the query editor:



This brings up the query editor.
Once the editor has started, select the target query. For this example, we selected the FactInternetSales query.

Click on the Manage Columns button to bring up the Choose Columns pop-up. Alternatively, you can review the Applied Steps section and locate the step where you filtered out the column.  Applied Steps provides a chronological listing of filters that you made to the raw data source. Locate the step where you removed columns. It's labeled:  Removed Other Columns. Locate the 'Gear' to the right of the Applied Step, and click on it.



Both approaches bring up the detailed choose column editor.



Choose Columns Pop-up

With the Choose Column pop-up, select the new columns to be added.  Or, remove any unwanted columns. Select 'OK' and your query columns have been updated to the results set.