Sunday, September 23, 2018

Sort a table (Power Query)

Sort a table (Power Query)

Note: Power Query is known as Get & Transform in Excel 2016. Information provided here applies to both. To learn more, see Get & Transform in Excel 2016.

I want to

Sort a table based on a single column

Sort a table based on multiple columns

Sort a table in Query Editor based on a single column

  1. In Query Editor, select the column you want to sort on.

  2. Click the down arrow ( Down arrow ).

  3. From the drop-down menu, click Sort Ascending (from low to high) or Sort Descending (from high to low).

Select sort order

Top of Page

Sort a table in Query Editor based on multiple columns

When you sort based upon multiple columns, the order or hierarchy of the sorting is based on the order that the columns were selected.

To sort a table based on multiple columns

  1. In Query Editor, select the primary column for the sort.

  2. Click the down arrow ( Down arrow ).

  3. From the drop-down menu, click Sort Ascending or Sort Descending.

  4. Repeat steps 1-3 for each subsequent column you want to use for sorting.

For example, when you sort by State then Population, the final result is a table ordered by state with the cities in each state ordered by population. Alphabetically Arizona comes before California and within Arizona Phoenix has more people than Tucson. The formula lists each sort column in sort priority and the type of sort to apply to it.

Sort example

Top of Page

Note: The Query Editor only appears when you load, edit, or create a new query using Power Query. The following video shows the Query Editor window appearing after editing a query from an Excel workbook. To view the Query Editor without loading or editing an existing workbook query, from the Get External Data section in the Power Query ribbon tab, select From Other Sources > Blank Query. The following video shows one way to display the Query Editor.

How to see Query Editor in Excel

No comments:

Post a Comment