Sort a table (Power Query)

Important   This article applies to Power Query, a data analysis feature available for Excel that lets you discover, combine and refine data. You may need to enable Power Query in Excel. You can also download and install the most recent version of Power Query for Excel, which automatically enables it. Power Query technology is also built into the Power BI Designer, which is a stand-alone report authoring and data transformation tool for Power BI.

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

Applies To: Excel 2013, Excel 2010



Was this information helpful?

Yes No

How can we improve it?

255 characters remaining

To protect your privacy, please do not include contact information in your feedback. Review our privacy policy.

Thank you for your feedback!

Support resources

Change language