cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mfa
Frequent Visitor

Dynamically Rank Items Based on Sales per Month

Hello All,

 

I'm Trying To generate the Rank Column in the following Table

 

MonthColumn1CustomerSalesMonthly Customer SalesRank
1-JanJanCustomer1         20,714         73,9082
2-JanJanCustomer1         27,793         73,9082
3-JanJanCustomer1         25,401         73,9082
4-JanJanCustomer2         25,445         78,9711
5-JanJanCustomer2         26,388         78,9711
6-JanJanCustomer2         27,138         78,9711
7-JanJanCustomer3         14,017         73,4353
8-JanJanCustomer3         29,776         73,4353
9-JanJanCustomer3         29,642         73,4353
1-FebFebCustomer1         21,175         55,0233
2-FebFebCustomer1         10,873         55,0233
3-FebFebCustomer1         22,975         55,0233
4-FebFebCustomer2         26,087         57,0762
5-FebFebCustomer2         20,605         57,0762
6-FebFebCustomer2         10,384         57,0762
7-FebFebCustomer3         29,730         71,8561
8-FebFebCustomer3         12,634         71,8561
9-FebFebCustomer3         29,492         71,8561
1-MarMarCustomer1         24,603         62,7132
2-MarMarCustomer1         10,636         62,7132
3-MarMarCustomer1         27,474         62,7132
4-MarMarCustomer2         24,958         61,0913
5-MarMarCustomer2         15,683         61,0913
6-MarMarCustomer2         20,450         61,0913
7-MarMarCustomer3         18,982         72,6611
8-MarMarCustomer3         24,464         72,6611
9-MarMarCustomer3         29,215         72,6611

 

Rank here would be described as Rank of the Customer Total Sales per Given Month on a given month

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Picture1.png

 

New Table =
SUMMARIZECOLUMNS (
Dates[Month Name],
Customers[Customer],
"@monthly sales", SUM ( Sales[Sales] ),
"@monthly sales rank",
VAR _currentmonth =
MAX ( Dates[Month Name] )
VAR _ranktable =
SUMMARIZE (
CALCULATETABLE (
ALL ( Sales ),
Dates[Month Name] = _currentmonth
),
Customers[Customer]
)
VAR _ranking =
RANKX (
_ranktable,
CALCULATE (
SUM ( Sales[Sales] )
),
,
DESC
)
RETURN
_ranking
)
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Picture1.png

 

New Table =
SUMMARIZECOLUMNS (
Dates[Month Name],
Customers[Customer],
"@monthly sales", SUM ( Sales[Sales] ),
"@monthly sales rank",
VAR _currentmonth =
MAX ( Dates[Month Name] )
VAR _ranktable =
SUMMARIZE (
CALCULATETABLE (
ALL ( Sales ),
Dates[Month Name] = _currentmonth
),
Customers[Customer]
)
VAR _ranking =
RANKX (
_ranktable,
CALCULATE (
SUM ( Sales[Sales] )
),
,
DESC
)
RETURN
_ranking
)
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!

Top Solution Authors