Excel Data Model: How to Sort Two Columns Together

Formulas & functions · Updated November 18, 2026

Yes—but the right method depends on what you mean by “sort two columns.” In Excel for Microsoft 365 on Windows, use a PivotTable to sort two row fields as a hierarchy, or use Power Pivot’s Sort by Column setting when one field needs a specific order defined by another; the Data Model itself does not store a permanent, general-purpose two-column row order.

What “sort two columns” means in a Data Model

Excel’s Data Model stores related tables and their values for analysis. It is not a worksheet range that you can permanently rearrange by selecting two headers and choosing a multi-level sort. A model table’s displayed row order is not a reliable instruction for how records should appear in a PivotTable or other report.

People usually mean one of three different tasks:

  • Sort a report by two fields: for example, show regions alphabetically and products alphabetically within each region. Set up both fields as PivotTable row fields and sort each level.
  • Give labels a meaningful order: for example, display month names from January to December instead of alphabetically. Set the month-name column to sort by a month-number column in Power Pivot.
  • Order records by two keys: for example, sort a flat list by date and then by customer name. Create that order in the report or upstream query; sorting the model’s rows is not a dependable way to control the final display.

Choosing which task applies matters. The Power Pivot setting handles a label-to-sort-key relationship, while PivotTable sorting arranges the results being displayed. They are related tools, but they do not do the same job.

Sort a label by another column in Power Pivot

Use Sort by Column when each displayed label should have a consistent corresponding sort value. The classic example is a Month Name field and a Month Number field: “April” should be ordered using 4, not the alphabetic position of its name.

  1. Make sure the table in the Data Model contains both the label column and its sort column. For months, those might be MonthName and MonthNumber.
  2. On the Power Pivot tab, select Manage to open the Power Pivot window.
  3. In Data View, select the label column you want to display, such as MonthName.
  4. On the Home tab, choose Sort by Column, then select the column that supplies the order, such as MonthNumber.
  5. Use the label field in your PivotTable. It should follow the defined month-number order rather than alphabetical order.

The sort column must provide a consistent ordering for the displayed values. In practical terms, every occurrence of a given label must correspond to the same sort value. A month name such as “March” cannot sensibly map to both 3 and 9 in the same label column. If your data contains several years, a month-name column may repeat across years, but it still needs to map consistently to the month number if the intention is to order months within a year.

This setting changes how the label column is ordered when used in reports; it does not move the underlying model records into a new physical sequence. Nor does it define a general two-key sort for every row in the table.

Can Sort by Column use two sort columns?

No. The Power Pivot Sort by Column relationship uses one sort column for the selected display column. It does not offer a dialog where you choose a primary key and a secondary tie-breaker. That distinction is easy to miss: having two columns in the model does not automatically create a two-level sort.

If your label order depends on two attributes, first decide what the report should show. For example, suppose a report needs fiscal periods ordered by fiscal year and period number. A single period label such as “P01” repeats in every fiscal year. Sorting that label by a combined year-and-period value would not represent one consistent order for “P01” across the whole column. Instead, put Fiscal Year and Period Number into the PivotTable as separate row fields, in that order, and sort each field. The hierarchy then expresses the intended sequence explicitly.

A helper sort key can be useful when a single displayed value has a unique intended position. It is not a universal fix for repeated labels that belong to different groups. If labels repeat with different intended positions, include the group field in the report or redesign the label so it identifies the intended item uniquely. For a large or complicated model, creating and documenting an explicit sort key in the source or Power Query can make the rule easier to maintain.

Sort two fields in a PivotTable

For a report with two columns of row labels, use a PivotTable hierarchy. For example, put Region above Product in the Rows area. Sorting Region ascending orders the groups; sorting Product ascending orders product labels within each region. The row fields’ order in the Rows area determines which field is the outer group and which is nested inside it.

To build that report, click inside the PivotTable and open the PivotTable Fields pane if it is not visible. Drag the first field, such as Region, to Rows, then drag Product below it in the same area. To sort a label field, right-click one of its displayed items and choose Sort, then select an ascending or descending option. You can repeat the sort for the other row field. The precise right-click options can vary with the selected cell and PivotTable layout, so confirm that you clicked a label from the field you intend to sort.

This method is appropriate for nested labels, not every interpretation of “sort by two columns.” If you want the entire flat result sorted first by a numeric measure and then by a text field only when values tie, a PivotTable’s hierarchical row-label sorting may not express that exact rule. Depending on the report, you may need to arrange the fields differently, use a helper field, or sort a normal worksheet output. Test the result with tied values rather than assuming a secondary sort has been applied.

Sorting the source or Power Query output

You can sort a source table on multiple columns before loading or refreshing it. In a worksheet table, use Data > Sort to add sort levels—for example, Region ascending followed by Product ascending. Power Query also supports sorting by successive columns in a query. These steps are useful for inspecting and preparing data, but they do not guarantee that a PivotTable built from the Data Model will preserve that row sequence.

That is because the PivotTable groups and summarizes model values; it applies its own display and sort behavior. A query’s sorted output can be helpful as an input or for a worksheet result, but do not rely on the source row order as the report’s permanent sort instruction. Specify the order in the PivotTable or use the model’s Sort by Column feature for labels that need a defined custom order.

For a flat, record-by-record output where row order is essential, a regular Excel table or a query result may be a better presentation layer than a PivotTable. Sort that output by the required fields and refresh it when its source changes. Keep the Data Model for relationships and analysis when those capabilities are needed.

Common problems and how to fix them

  • “Sort by Column” is unavailable: confirm that you are in the Power Pivot window, in Data View, and have selected a column. Check that Power Pivot is available and enabled in your Windows Excel installation.
  • The model rejects the chosen sort column: inspect whether a displayed value maps to more than one sort value. Correct inconsistent labels or use a different field design. A text label that occurs in several groups may not be suitable for a single global sort mapping.
  • Months still appear alphabetically: verify that the month-name column—not the month-number column—was selected before applying Sort by Column. Then check that the PivotTable uses that model field and refresh the PivotTable if necessary.
  • The second field seems to sort the whole report: check the Rows area order and the cell you right-clicked. In a hierarchy, the inner field is ordered within its parent groups; sorting one field does not turn the report into a general two-key flat-list sort.
  • Source sorting disappears after refresh: this is expected when the PivotTable applies its own ordering. Set the required sort in the report or use a custom label sort in the model rather than relying on the input rows’ sequence.

Power Pivot’s Data Model authoring tools, including the Power Pivot window described above, are for Excel on Windows. Excel for Mac does not provide the same Power Pivot model-management interface, and Excel for the web does not provide the full Power Pivot authoring workflow. If you need to configure Sort by Column, use a supported Windows desktop version of Excel with Power Pivot available.

Which method should you choose?

Use the goal, not the number of columns, to choose a method:

  • Choose Sort by Column when one label field needs a stable custom order supplied by one corresponding field, such as month name by month number.
  • Choose PivotTable row-field sorting when you want nested groups, such as region followed by product, and want each level ordered in the report.
  • Choose a multi-level worksheet or query sort when you need a flat record list ordered by a primary field and then a secondary field.
  • Use a helper key or revised model design only after checking whether labels repeat with different intended positions. A helper does not remove the need for each label’s sort rule to be unambiguous.

In short, Excel can show two levels of sorting, but there is no single Data Model command that permanently sorts all model rows by two arbitrary columns. Define the ordering where it belongs: in the label’s sort mapping, in the PivotTable hierarchy, or in the flat output.

Frequently Asked Questions

Can I sort a Data Model table by two columns at once?

Not as a permanent row order in the Data Model. Use a PivotTable for two-level display sorting, or set one label column to sort by one corresponding sort column in Power Pivot.

How do I sort month names chronologically in a PivotTable?

In Power Pivot, select the month-name column in Data View and use Home > Sort by Column to choose the month-number column. Then use the month-name field in the PivotTable.

Does sorting a table before adding it to the Data Model control PivotTable order?

No. A PivotTable applies its own grouping and sort behavior, so source row order is not a dependable display-order setting. Set the sort in the PivotTable or define a custom label order in the model.

Can one column be sorted by two different columns?

Sort by Column selects one sort column for a given display column. For a two-part hierarchy, use two PivotTable row fields, or redesign the labels and sort key so each displayed value has one consistent order.

Why can’t I find Sort by Column on a Mac?

The Power Pivot model-management window and its Sort by Column workflow are Windows features. Excel for Mac does not offer the same Power Pivot authoring interface; configure that setting in supported Windows desktop Excel.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.