cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Rfranca Member
Member

Ranking TOP N sales without zeros

 

I'm doing the sales rank, but when I set up the table for presentation the products that had sales with zero appear in the rank table, how do I mount the rank without the products with sales with zero.

 

Clipboard01.gif

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Ranking TOP N sales without zeros

Hi @Rfranca,

 

Try this measure in the Mx_sales table

 

=RANKX(FILTER(All('PRODUCT'[ProductName]),[Ttotal_Sales]>0),[Ttotal_Sales],,ASC,Skip)

 

In the Visual level filters, apply a criteria on the Ttoal_Sales of >0

 

Hope this helps.

 

Untitled.png

 

5 REPLIES 5
ccakjcrx Member
Member

Re: Ranking TOP N sales without zeros

Hey @Rfranca!

 

Try something like this: 

 

MsrRankNo0 = 
IF(
    CALCULATE(SUM(Sheet1[Sales])) <> 0,
    RANKX(ALL(Sheet1),CALCULATE(SUM(Sheet1[Sales])),,1,Skip) - 1
)

You have to subtract 1 to get the rank to start at 1. The calculate expressions are necessary; otherwise, you will get 1s for your ranks. Here is how that turned out on my test data:

 

Screenshot.jpg

 

Rfranca Member
Member

Re: Ranking TOP N sales without zeros

 

hi, @ccakjcrx @gooranga1 @MarcelBeug @vanessa

 

Unfortunately it did not work out.
I am sending the file for better understanding.

 

Sales.pbix

 

Thank you for your help.

Super User
Super User

Re: Ranking TOP N sales without zeros

Hi @Rfranca,

 

Try this measure in the Mx_sales table

 

=RANKX(FILTER(All('PRODUCT'[ProductName]),[Ttotal_Sales]>0),[Ttotal_Sales],,ASC,Skip)

 

In the Visual level filters, apply a criteria on the Ttoal_Sales of >0

 

Hope this helps.

 

Untitled.png

 

Rfranca Member
Member

Re: Ranking TOP N sales without zeros

hi, @Ashish_Mathur

 

Many thanks, it worked!

I forgot the criterion of the visual level filter.

 

Clipboard01.gif

Super User
Super User

Re: Ranking TOP N sales without zeros

You are welcome.

Helpful resources

Announcements
GregDeckler

How to Get Your Question Answered Quickly

Power BI Super User, Greg Deckler, explains

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Ideas
Users Online
Currently online: 229 members 2,843 guests
Please welcome our newest community members: