14 Replies Latest reply on May 5, 2016 5:30 AM by pooja.gandhi

# How to find Top 4 customers in each category based on sales??

I'm  trying to find top 4 customers based on sales in each category. i tried by using parameters,calculations and context filters too but i'm not getting the exact result which i want .It will be helpful if any one solve this.exactly i want in this way

Header 1Header 2Header 3
Furniture

sean miller

Jhon

michel

thomas

\$23,000

\$18,000

\$13,000

\$7,000

Office supplies

Jhon

michel

thomas

sean miller

\$25,000

\$12,000

\$5,000

\$4,000

Technology

michel

thomas

Jhon

sean miller

\$8,000

\$7,000

\$3,000

\$1,000

Waiting for replay................................

• ###### 1. Re: How to find Top 4 customers in each category based on sales??

Nested sorting has always been tricky in Tableau.

The attached workbook shows how to use Rank table calculation to do what you want (no combined fields necessary).

See the credited blog post for further explanation.

• ###### 2. Re: How to find Top 4 customers in each category based on sales??

Hi,

You can try this also

Mahfooj

1 of 1 people found this helpful
• ###### 3. Re: How to find Top 4 customers in each category based on sales??

create a cal field rank and mention as index ()

make discrete

• ###### 4. Re: How to find Top 4 customers in each category based on sales??

2 of 2 people found this helpful
• ###### 5. Re: How to find Top 4 customers in each category based on sales??

Hi Sangaraju,

Please find the attached workbook. I have created the created a index() calculation. Change it to discrete and put it in filter and select the 1,2,3 and 4. (you can see the output in the same.)

Then put the index calculation to the rows and keep it continuous and perform the following operation.

Screenshot for Compute using : Advanced

I hope this helps.

Thanks and Regards,

Ashish Chaudhari

• ###### 6. Re: How to find Top 4 customers in each category based on sales??

Thanks a lot for spending your time on this i want to extend the same query like....

Header 1

Header 2

Header 3

Furniture

sean miller

Jhon

michel

thomas

\$23,000

\$18,000

\$13,000

\$7,000

total\$61,000
Office supplies

Jhon

michel

thomas

sean miller

\$25,000

\$12,000

\$5,000

\$4,000

total\$46,000
Technology

michel

thomas

Jhon

sean miller

\$8,000

\$7,000

\$3,000

\$1,000

total\$19,000
grand total\$1,26,000

Thanks and Regards

Haripriya.

• ###### 7. Re: How to find Top 4 customers in each category based on sales??

Thanks a lot for spending your time on this i want to extend the same query like....

Header 1

Header 2

Header 3

Furniture

sean miller

Jhon

michel

thomas

\$23,000

\$18,000

\$13,000

\$7,000

total\$61,000
Office supplies

Jhon

michel

thomas

sean miller

\$25,000

\$12,000

\$5,000

\$4,000

total\$46,000
Technology

michel

thomas

Jhon

sean miller

\$8,000

\$7,000

\$3,000

\$1,000

total\$19,000
grand total\$1,26,000

Thanks and Regards

Haripriya.

• ###### 8. Re: How to find Top 4 customers in each category based on sales??

Hi,

From analysis tab you can have option for subtotals as well as grand totals. See the screen shot.

Mahfooj

• ###### 9. Re: How to find Top 4 customers in each category based on sales??

If you get your desired output then close the thread. You haven't close this thread if you see your first question so many users have posted their answers which might have helped you to get the right answer of your first query. Try to close that thread don't continue with new question in the old thread. If you close the thread with mark as correct then that thread will be helpful for other users who have similar kind of query and they can refer your post.

For new query always post it with new thread. I hope you get my point.

Mahfooj

• ###### 10. Re: How to find Top 4 customers in each category based on sales??

Hi,

I tried it but the result was wrong,because when i'm working with

subtotal and grand totals the result is showing the subtotal of all the

customer sales in each Category, Grand total for all the categories . But i

want the subtotal of top 4 customers in each category and grand total of

those customers.

Thanks and Regards,

Haripriya.

On Wed, May 4, 2016 at 10:44 PM, Mahfooj Khan <tableaucommunity@tableau.com>

• ###### 11. Re: How to find Top 4 customers in each category based on sales??

Hi Mahfooj,

Please refer to the screenshot. I tried to check the underlying data and its giving me the sales of all the customer instead of showing sales for the filtered customers.

Any idea what is wrong here?

Thanks and Regards,

Ashish Chaudhari

• ###### 12. Re: How to find Top 4 customers in each category based on sales??

Pooja Gandhi, Joe Oppelt can you help on this one? You can find the attached workbook in my reply.

Thanks in Advance.

• ###### 13. Re: How to find Top 4 customers in each category based on sales??

I think due to index filter which you have put in filter shelf. Why its discrete?

See I've done the same thing top4 customers based on sales for category Furniture.

Drag the index to filter shelf and put table calculation as per below screen shot. And filter top4 from edit filter.

Let me know If you've any query.

Mahfooj

• ###### 14. Re: How to find Top 4 customers in each category based on sales??

Hi Ashish!

Thanks for the ping! I think this is one of the most common questions on the forums. Why do my grand totals not work when I have a table calculation? Jonathan and Joe give a terrific explanation on their blogs. Refer to this:

Customizing Grand Totals – Part 1 | Drawing with Numbers

Customizing Grand Totals – Part 2 | Drawing with Numbers