Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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]
)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
10 | |
10 | |
9 | |
9 |
User | Count |
---|---|
20 | |
13 | |
12 | |
11 | |
8 |