Get started with Power Query – connect to data and add an Index

Get started with Power Query - connect to data and add an Index
The most useful features of Excel’s Power Query are the ability to connect easily to different types of data sources and then manipulate the data.
The benefits of working with a dataset in Power Query are that you can:
  • create a connection without having to import the whole datatable (save time loading a large dataset),
  • work with a subset of the data,
  • build multiple data queries step by step,
  • repeat the data query on different datasets,
  • combine data sets from several files or data sources into one data table,
  • maintain the raw data file untouched,
  • refresh data queries via the data connection when the data source is updated.

Note: Power Query is known as ‘Get & Transform’ in Excel 2016.

Screenshot of Get Data dropdown in Excel

Video player icon
Step 1: Connect to an Excel workbook using Power Query — start from Get Data | From File | From Workbook

Method (shown in video above) — Step 1: connect to data using Power Query
Power Query import data dialog box
Excel import data dialog box
  1. From the ‘Get data‘ section of the ribbon, click on Get Data | From File | From Workbook.
  2. In the ‘Import Data‘ window, browse to the Excel workbook (.xlsx) file that contains the data to connect to.
  3. Select the file and click ‘Import‘.
  4. A Navigator window opens which lists the worksheets and tables contained in the workbook.
  5. Select the worksheet or table to import.
  6. From the ‘Load‘ dropdown button, select ‘Load to…‘.
  7. The ‘Import data’ dialog box opens, and select ‘Only Create Connection‘.

Video player icon
Step 2: Add an index to a data table with Power Query

Method (shown in video above) — Step 2: add an index to a data table using Power Query
  1. When a Power Query connection is made to a dataset, as in Step 1 above, the query will appear in the ‘Queries & Connections‘ pane on the right-hand side of the Excel window.
  2. You can build a second query based on this first query, by right-clicking the query block, and selecting ‘Reference‘.
  3. A new ‘Power Query Editor‘ window opens.
  4. To add an index, click on the ‘Add Column‘ tab in the window, and click on the ‘Index Column‘ dropdown.
  5. To add an Index starting at 1 for the first record, select the option ‘From 1‘.
  6. To move the new Index column to become the first column in the data table, right-click on the column header, and select Move | To beginning. Other options are ‘Left‘, ‘Right‘, ‘To End‘.
  7. You can rename this query by over-writing the ‘Name’ field in the Properties section of the editor window.
  8. To save the query, from the ‘Home tab‘, select ‘Close & Load To…‘, and you have the choice of whether to save this query as another ‘connection only’ query, or to load the data table to a worksheet in the workbook.