Showing results for 
Search instead for 
Did you mean: 
seanwu Frequent Visitor
Frequent Visitor

Ranking the Order Date



I am still learning DAX. But I am running into a problem.


I have a "Sales" table that lists all the sales by "CustomerKey", "OrderDate" and "OrderAmount" and a bunch of other columns that are not the focus of my concern for this purpose.  In this "Sales" Table, one "CustomerKey" can have mulitiple "OrderDate"s. One "CustomerKey" can have mulitple orders on the same day too. 


I want to create a table (named "CleanTable") by using SUMMARIZECOLUMNS as follows:


The purpose of this "CleanTable" is to get rid of those "other columns" that are not the focus of my concern and also Summarize the "Sales" table by CustomerKey and OrderDate.


CleanTable is created with no glitch. Now I want to add a column (Let's call it "OrderDateRank")to the CleanTable to rank the OrderDate column WITHIN each CustomerKey.  For example, if CustomerKey 1 in the CleanTable has three OrderDate (7/15/2018, 7/16/2018, 7/17/2018), then this "OrderDateRank" will have value 1 to 7/15/2018, 2 to 7/16/2018 and 3 to 7/17/2018).


How can I do that? The key is that it has to be within each CustomerKey, NOT All across all the OrderDate.


Thanks a lot.

Community Support Team
Community Support Team

Re: Ranking the Order Date

Hi @seanwu ,

I have still a little confused about your scenario.

If it is convenient, could you share the data sample with table format and your desired output so that we could help further on it?

Please refer to this blog about how to get your question answered quickly.

Best Regards,



Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
seanwu Frequent Visitor
Frequent Visitor

Re: Ranking the Order Date

Hi v-piga-msft,


Thanks for looking into this.


I saved a file on DropBox.


As you can see, there is a sales table with Customer Name, Year, Country and Sales Amount. 


I want a couple of Rankings in calculated columns of this sales table.


The first one I created myself: RankAcrossAll, as its name indicates, it ranks all customers across all years and countries based on their sales amount. 


I run into difficulty in creating the following two rankings:


1. Rank customers, Within each country, but across years, by sales amount.

2. Rank customers, Within BOTH each country and Year by sales amount


Thank you again for your time and attention.





Helpful resources

Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 295 members 3,543 guests
Please welcome our newest community members: