Forum Discussion
Ranking the Order Date
Hi,
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.
2 Replies
- v-piga-msft
Resident Rockstar
- seanwuRegular Visitor
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.
SeanWu