Forum Discussion
Calculated column RANKX with multiple columns
- 4 years ago
Hi Anonymous
The problem is because of that change you did in the code, remove that SUM from line 4 in the code (based on the screenshot you sent)
try this and don't change anything (copy past):
Rankx = RANKX ( FILTER ( ALL ( 'Sales' ), [Customer] = EARLIER ( 'Sales'[Customer] ) ), [Sales], , DESC, DENSE )Output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
Hi Anonymous
Try this to add a Rankx column:
Rankx =
RANKX (
FILTER ( ALL ( 'Table' ), [Customer] = EARLIER ( 'Table'[Customer] ) ),
[Sales],
,
DESC,
DENSE
)
then this to add Top N + Other column:
Top N + Other =
if([Rankx]<=3,[Product],"Other")
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
- Anonymous4 years agoNot applicable
hi VahidDM
thanks for your advise. However, the RANKX formula doesn't work. It came out as all "1". Basically I would like to know the top 3 products for each of the customers and the rest will be grouped as "Others" for each customer. How should I get around with that?
Thank you!
- VahidDM4 years agoSuper User
HI Anonymous
Can you copy and past a sample of your data table here (in table format to be able to copy and past that)?
Those Codes in my previous post are need to be used to add new columns.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/- Anonymous4 years agoNot applicable
Hi VahidDM
Here you go!Customer Product Sales Ally Product A 1,000 Ally Product D 200 Ally Product A 1,000 Ally Product B 300 Ally Product B 300 Ally Product C 50 Jason Product A 1,000 Jason Product A 1,000 Jason Product A 1,000 Jason Product A 1,000 Jason Product B 200 Jason Product C 100 Jason Product D 60 Below is the screenshot of outcome in PowerBI:
The outcome i desire is as below:
Appreciate your help as i am very new to PowerBI and DAX!
Thank you!!