3 Replies Latest reply on Jul 17, 2017 8:14 AM by Sarah Leonard

# Rank by Percent of Total

Hi all,

I am trying to sort my data set based on a quick calculated percent and it is proving much more difficult than I thought - I'm sure I'm missing something very basic.

Essentially I am trying to do the following:

I want to take a count of items that fall into one of two categories (calculated field).

Calculate the percent of total for each location or row. (ie. Location A has 30% of items in category 1 and 70% in category 2). - I used a quick calculation based on cell

Rank each location (row) by percent in ascending order.

My rank is ordering by the count of items instead of the actual % of total. I have attached a workbook with the super store sample data that closely replicates what I want to accomplish.

Any help is appreciated.

• ###### 1. Re: Rank by Percent of Total

I think you should be able to do this by using proper addressing and partitioning in your table calculations.

I cannot open your workbook - I am using Tableau 9.3; is it saved in a newer version?

• ###### 2. Re: Rank by Percent of Total

Hi Naveen,

I forgot to mention that I am using Tableau 10 beta.

I attached a workbook saved in 9.3.

• ###### 3. Re: Rank by Percent of Total

Hello Ryan,

I'm a bit late to the party here. I had the same question and was just searching for an answer before I worked out what to do myself. If this isn't relevant anymore than maybe someone else can use this info

You can work this out using an LoD expression:

Proportion of Customers=COUNT([Customer Name])/SUM({ FIXED [Segment]:COUNT([Customer Name])})

This will give you the same result as before - included on sheet 'LoD'

Next, use this to create a rank:

Rank by Customer Count= RANK([Proportion of Customers]) - Compute using Segment

Convert this to Discrete

You can then filter by Ship Mode and it will return the rank for each Segment. You can untick Show Header for the Rank field if you don't want to see the 1,2,3

Was this what you were aiming for? - sheet 'Rank by Ship Mode'

N.B. Personally, I always use Count Distinct rather than Count, as this counts the unique customer names, but this may not be relevant for your data

Hope this helps

Attached in v 10.3