Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi masters,
I wish to a add a calculated column of ranking orders by date and customer for a specific Product. Demo data below:
please assist with the correct DAX
thanks!
Solved! Go to Solution.
Assuming you have a table named Orders with columns OrderID and OrderDate, you can add a calculated column to calculate the day of the year and then use it for sorting:
DayOfYear = YEAR(Orders[OrderDate]) * 1000 + DAYOFYEAR(Orders[OrderDate])
This expression combines the year and the day of the year to create a unique numeric value like 2023001 for January 1st, 2023, and so on
1. Now, you can sort the OrderID based on this calculated column. Go to the "Modeling" tab and select the Orders table.
2. In the "Sort by Column" option, choose the DayOfYear column
3.Finally, make sure to use the DayOfYear column as the sorting column in your visuals where you want to sort by this rank.
OR
OrderSequence =
RANKX(
FILTER(
Orders,
Orders[CustomerID] = EARLIER(Orders[CustomerID]) &&
Orders[ProductID] = EARLIER(Orders[ProductID])
),
Orders[OrderDate]
)
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LearnAndPractise(Everyday) ) |
What if you just take the day of year?
didnt understand your suggestion.
i need to figure out what is the customer X product 1st order, 2nd order, 3rd and so on... day of year has nothing to do with that.
Assuming you have a table named Orders with columns OrderID and OrderDate, you can add a calculated column to calculate the day of the year and then use it for sorting:
DayOfYear = YEAR(Orders[OrderDate]) * 1000 + DAYOFYEAR(Orders[OrderDate])
This expression combines the year and the day of the year to create a unique numeric value like 2023001 for January 1st, 2023, and so on
1. Now, you can sort the OrderID based on this calculated column. Go to the "Modeling" tab and select the Orders table.
2. In the "Sort by Column" option, choose the DayOfYear column
3.Finally, make sure to use the DayOfYear column as the sorting column in your visuals where you want to sort by this rank.
OR
OrderSequence =
RANKX(
FILTER(
Orders,
Orders[CustomerID] = EARLIER(Orders[CustomerID]) &&
Orders[ProductID] = EARLIER(Orders[ProductID])
),
Orders[OrderDate]
)
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 20 | |
| 10 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 32 | |
| 31 | |
| 18 | |
| 12 | |
| 11 |