Yes, you can sort a Power BI table by multiple columns, but you cannot do it directly from the visual’s sort headers. You must use the Fields pane or the Data view in the Power BI Desktop tool to set a hierarchical sort order. This allows you to sort by a primary column, then by a secondary column, and even a tertiary column if needed. The visual will then respect this order when displaying the data.
What You'll Need
- A computer with Power BI Desktop installed.
- A live or imported dataset that contains at least two relevant columns of data.
- A basic understanding of how to navigate the Power BI Desktop interface.
Step-by-Step
- Open your Report or Data View. Launch Power BI Desktop and open the report file you want to edit. Depending on your workflow, you can stay in the Report view or switch to the Data view. The Data view is often more intuitive for this task because it shows the table structure of your source data, but the Report view works equally well if you prefer to stay there.
- Locate the Fields Pane. On the left-hand side of the Power BI Desktop window, you will see a pane labeled “Fields.” If you do not see it, go to the View tab on the ribbon toolbar and check the box for “Fields” to make it visible.
- Drag the Primary Column to the Sort Order. Find the column you want to use as your main sort key in the Fields pane. Drag that column and drop it onto the “Sort by” section of the Fields pane. This section is usually located just below the list of fields. Once you drop it, Power BI will automatically apply a sort to this column in your visuals. If you are in the Data view, you will see the table reorganize immediately. In the Report view, you may need to click the visual to refresh the sort.
- Drag the Secondary Column to the Sort Order. Now, find the column you want to use as your secondary sort key. Drag this column and drop it onto the “Sort by” section of the Fields pane, directly below the primary column you just added. It will stack beneath the first one. This tells Power BI: “First, sort by Column A, and then, for rows that have the same value in Column A, sort by Column B.” This nested logic is the core of multiple sorting.
- Drag Additional Columns (Optional). If you need a third or fourth layer of sorting, repeat the process. Add more columns to the “Sort by” section in the order from left to right (primary to tertiary). The leftmost column is the highest priority, and the rightmost column is the lowest priority.
- Verify the Sort in a Table Visual. To confirm the sort is working correctly, create a table visual (or use an existing one) that includes all the columns you added to the sort order. Look at the visual. The data should be grouped by the first column, and within each group, the rows should be ordered by the second column. If the visual is not updating, try clicking anywhere inside the visual to refresh it.
- Check the Sort Icons. Look at the header of the first column in your visual. You should see a sort icon (usually an arrow pointing up or down) indicating the sort direction. Clicking this icon toggles the sort order (ascending or descending). Note that this icon only controls the visual's sort, not the global sort order in the Fields pane. You can have a visual sorted ascending while the global sort order is descending.
- Save the Report. Once you are satisfied with the sort order, save your report. The sort order is saved with the report file, so it will be applied automatically the next time you open it.
Common Mistakes
A common mistake is trying to sort a visual by holding the Shift key while clicking the second column header in a table visual. Power BI does not support multi-column sorting via the visual header alone. This method will only sort the visual by the most recently clicked column. To achieve a true multiple sort, you must use the Fields pane method described above.
Another frequent issue is confusion between the visual’s sort and the data model’s sort. The visual’s sort is temporary and specific to that visual instance. The sort order in the Fields pane is a model-level setting that applies to all visuals that use those fields. If you sort in the visual but do not set it in the Fields pane, the sort will disappear if you add a new visual with those fields or if you refresh the data.
Tips
When sorting by text columns, be aware of case sensitivity. By default, Power BI sorts text in a case-insensitive manner, but the exact behavior can depend on the underlying data source and the collation settings. If you need strict case-insensitive sorting, you might need to create a calculated column that normalizes the text (e.g., using LOWER() or UPPER()) and sort by that calculated column instead.
For numerical columns, check that the data type is correct. If a column is formatted as text (e.g., “00123” instead of 123), it will be sorted alphabetically, leading to unexpected results. Ensure the data type is set to Whole Number or Decimal Number in the data view before sorting.
Troubleshooting
If your table is not sorting as expected, the first thing to check is whether the columns are correctly placed in the “Sort by” section of the Fields pane. The order of the columns there determines the sort hierarchy. If the secondary column is placed above the primary column, it will take precedence.
If you are in the Report view and the visual is not updating, try clicking the visual to give it focus. Sometimes, visuals do not refresh automatically when the underlying data changes or when the sort order is modified. Clicking the visual forces a refresh.
If you are using a DAX measure or a calculated column in your visual, ensure that the sort order is applied to the column or measure itself, not just the field in the Fields pane. You can right-click a column or measure in the Fields pane and select “Sort by” to specify a sort column or measure for that specific field.
If you are working with a live connection to a database, the sort order might be applied by the database server. In this case, you may not be able to change the sort order in Power BI Desktop. You would need to change the sort order in the source database itself.
Frequently Asked Questions
Can I sort a Power BI table by multiple columns on the web version of Power BI?
No, the web version of Power BI does not currently support multi-column sorting via the visual interface. You can only sort by a single column. You would need to use Power BI Desktop to create the sort order and then publish the report to the web.
Does the sort order apply to all visuals in the report?
Not necessarily. The sort order in the Fields pane applies to all visuals that use those specific fields. However, a visual can override the global sort order by having its own sort settings applied. If a visual is sorted by a specific column, it will display that sort regardless of the global sort order.
Why is my table sorted alphabetically instead of numerically?
This usually happens when the data type of the column is set to “Text” instead of “Whole Number” or “Decimal Number.” Power BI interprets text strings alphabetically, so “10” will appear before “2.” You can fix this by changing the data type in the Data view.
How do I remove a sort order?
To remove a sort order, simply click on the column name in the “Sort by” section of the Fields pane and press the Backspace or Delete key. Alternatively, you can drag the column out of the “Sort by” section and drop it back into the main list of fields.
Can I sort by a calculated column?
Yes, you can. You can create a calculated column in the Data view and then drag it to the “Sort by” section of the Fields pane, just like any other column. The sort order will be applied based on the values generated by the calculated column.
Does sorting a table affect the underlying data?
No. Sorting is a visual operation. It only changes the order in which the data is displayed in the visual. It does not modify the original data in the source database or file.