Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

TopN and Ranking

Hello 

 

I have a set of data, as below.  I need to achieve the following:

  • summarise the customers
  • total the sales for each customer
  • rank the customer by total sales
  • put any customer outside top 2 as "other"

Finally, I need the table/rank to change if my slicer of vendor, for example, changes.

 

Any ideas?  

 

Thanks 

 

Data example:

 

Customer            Sales             Vendor

a                            100                    a

a                            100                    a

a                            100                    a

b                            100                    b

b                             50                    a

b                            100                    b

c                              10                    c

c                              50                    a

c                            100                    a

d                             90                    b

d                             20                    c

d                             60                    a

e                            100                    c

e                              75                    b

e                              50                    b

f                               40                    a

f                               90                    c

f                               75                    b

 

1 ACCEPTED SOLUTION
LivioLanzo
Solution Sage
Solution Sage

@Anonymous

 

Hello @Anonymous,

 

you need to build the below simple model

 

and add the below measures:

 

TotalSales = SUM( Sales[Sales] )
 
Customer Rank = 
IF(
    COUNTROWS( Sales ) > 0,
    VAR Ranking = 
    IF(
        HASONEVALUE( Customers[Customer] ),
        RANKX(
            ALLSELECTED( Customers[Customer] ),
            [TotalSales],,DESC
        )
    )
    RETURN IF( Ranking < 3, Ranking, "Other" )
)

 

Capture.PNG

 
Capture.PNG

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

View solution in original post

1 REPLY 1
LivioLanzo
Solution Sage
Solution Sage

@Anonymous

 

Hello @Anonymous,

 

you need to build the below simple model

 

and add the below measures:

 

TotalSales = SUM( Sales[Sales] )
 
Customer Rank = 
IF(
    COUNTROWS( Sales ) > 0,
    VAR Ranking = 
    IF(
        HASONEVALUE( Customers[Customer] ),
        RANKX(
            ALLSELECTED( Customers[Customer] ),
            [TotalSales],,DESC
        )
    )
    RETURN IF( Ranking < 3, Ranking, "Other" )
)

 

Capture.PNG

 
Capture.PNG

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.