Dax Function: ORDERBY
Reviewed by Neetu Singla — Founder, Lets Viz Technologies — AI & Data Consultant. Last reviewed April 27, 2026.Category: Filter Functions
The ORDERBY function in Power BI is used to specify the sort order for a table or dataset. It allows users to order rows based on one or more columns, either in ascending or descending order.
Purpose
Row Ordering: Define a logical order for rows in a table or query.
Sorting for Analysis: Facilitate operations like ranking, aggregation, and navigation by organizing data.
Time-Series Preparation: Arrange chronological data to ensure calculations like running totals or moving averages are correctly aligned.
Type of Calculations
Orders data based on one or multiple fields.
Enables hierarchical or compound sorting (e.g., sort by Region, then by Sales).
Practical Use Cases
Rank Calculation: Use ORDERBY with RANKX to rank items based on sales or performance.
Navigation Functions: Combine with OFFSET or EARLIER for row navigation.
Custom Aggregation: Ensure correct order for cumulative totals or rolling averages.
ORDERBY(<table>, <column>, [SortOrder], ...)</column></table>
| Parameter | Type | Description |
|---|---|---|
Table | Table | The table to be ordered. |
Column | Column | The column used for sorting. |
SortOrder | Enum (opt) | Specifies ascending (ASC) or descending (DESC) order. Defaults to ascending. |
How Does ORDERBY Dax Works
Sorting: Applies sorting criteria to the specified column(s).
Multi-Level Sorting: Orders rows hierarchically when multiple columns are provided.
Integration: The sorted result can be used in functions like RANKX, SUMMARIZE, or CALCULATETABLE for further analysis.
Formula Example:
To rank sales by region and then by product within each region:SortedTable = ORDERBY(Sales, Sales[Region], ASC, Sales[Product], DESC)
What Does It Return?
Table: Returns the input table with rows sorted according to the specified column(s) and order.
When Should We Use It?
Preparing data for ranking or relative comparisons.
Organizing data for time-based calculations like trends or growth rates.
Structuring data hierarchically for reports or dashboards.
Examples
Basic Usage :
Sort a sales table by the Amount column in descending order:
SortedTable = ORDERBY(Sales, Sales[Amount], DESC)
Column Usage
Sort by multiple fields, first by Region in ascending order and then by Sales in descending order:
SortedTable = ORDERBY(Sales, Sales[Region], ASC, Sales[Amount], DESC)
Advanced Usage
Integrate ORDERBY with RANKX to rank products by sales within each region:
RankBySales = RANKX(ORDERBY(Sales, Sales[Region], ASC, Sales[Amount], DESC), Sales[Amount])
Tips and Tricks
Use Multi-Level Sorting: Specify multiple columns for complex sorting requirements.
Default Sorting: Ascending order is used if no
SortOrderis specified.Combine with Functions: Integrate with RANKX or SUMMARIZE for advanced analytics.
Performance Impact of ORDERBY DAX Function:
Index Optimization: Ensure the sorted column is indexed for faster processing.
Large Datasets: Sorting may become resource-intensive for massive datasets; consider pre-sorting during data ingestion.
Related Functions You Might Need
RANKX: Compute ranks based on sorted data.
SUMMARIZE: Group data by specific columns, optionally sorted with ORDERBY.
OFFSET: Navigate rows in a sorted dataset.
CALCULATETABLE: Apply sorting before filtering or aggregation.
Want to Learn More?
For more information, check out the official Microsoft documentation for ORDERBY You can also experiment with this function in your Power BI reports to explore its capabilities.
Unlock the full capabilities of Power BI and elevate your data insights with our specialized consulting services. Whether you need guidance on advanced DAX functions like those highlighted here, support in designing interactive dashboards, or expertise in optimizing data models for enhanced performance, our experienced Power BI consultants are equipped to deliver customized solutions for your business. Explore our Power BI Consulting Services page to discover how we can help your organization make smarter, data-driven decisions.
It sorts rows in a table based on specified column values and sorting order.
Yes, you can specify multiple columns and their sort orders in a single function.
The default sorting order is ascending (ASC).
While Excel sorts data statically, ORDERBY dynamically orders data within DAX queries and calculations.
Yes, ORDERBY is essential for functions like RANKX to define the sequence of rows.
Need a Power BI consultant for your team?
We've built Power BI dashboards and data automation for 100+ clients across finance, sales, operations, and executive reporting. Fixed-fee MVPs, first production dashboard in 3–4 weeks.
- Finance BI — P&L, balance sheet, budget vs actual, cash forecast
- Sales BI — CRM data cleaned, pipeline and forecast dashboards leadership trusts
- Operations BI — real-time KPIs with validation and alerting built in
- Embedded Power BI inside SaaS products with row-level security
See the Fortivis case study for a real example: an Athens-based financial advisory firm that replaced their multi-day manual reporting cycle with a validated Power BI pipeline.
ORDERBY vs RANKX vs TOPN (sorting approaches)
| ORDERBY | RANKX | TOPN | |
|---|---|---|---|
| Purpose | Define sort order inside a window function | Return rank of a value in a table | Return top-N rows of a table |
| Returns | Sort specification (not a value) | Integer rank | Table |
| Works standalone | ✗ must be inside a window function | ✓ | ✓ |
| Handles ties | — (no tie logic, just sort) | ✓ skip / dense options | Includes ties by default |
| Window function era | ✓ 2022+ | ✗ pre-window legacy | ✗ pre-window legacy |
| When to use | Any WINDOW / RANK / OFFSET / ROWNUMBER call | Rank a measure across a table in a measure | Return the top-N rows as a table for iteration |
Need Power BI help in a real engagement?
Our team writes DAX like this every day for SaaS finance and ops teams. Refresh monitoring, change requests with a 2-business-day SLA, and a named analyst on retainer — or scoped hourly help if you just need a fix.
Named analyst2-day SLAFrom $5K/mo
