6 Replies Latest reply on May 16, 2017 1:28 AM by Łukasz Majewski

# Top N for labels

I have a map of states and I color the background by % growth of volume. How can I add labels with growth % but only for the top 5 volume states?

Thanks

• ###### 1. Re: Top N for labels

Hi Alex,

I'd suggest using Rank().  Once you get the Rank calculation to give the expected result, you could make a secondary calculation something like this:

IIF( [Rank] <=5, [Label], NULL )

If you're having trouble with Rank calculations, check out the Tableau documentation on Table Calculations.

Best,

Jeff

1 of 1 people found this helpful
• ###### 2. Re: Top N for labels

Hello.

I tried this formula and it worked. Rank([YTD Closings True]). It showed me all the states ranks in a table.

Then I created this formula based off of your suggestion. I then placed it in labels but it is still showing every state.

IIF([Closings State Rank] <= 5, [YTD Closings True],NULL)

• ###### 3. Re: Top N for labels

Here is a dummy sheet replicating my setup and following your insturctions I couldn't get it to work. Thanks.

• ###### 4. Re: Top N for labels

Anyone?

• ###### 5. Re: Top N for labels

Hi Alex,

I'm on an older version of Tableau, so I can't open your workbook.  I always have to fiddle around with table calcs to get them to calculate how I want.  My guess is that your two calculations have different settings in the Table Calcs menu.  If you drag the working Rank to the list of measures on the left of your screen, it'll turn into a saved calculation with the same settings.  Try doing that, and using that saved calculation in your second calculation, and *hopefully* it'll work.

Hopefully someone who is better with table calcs will come along and be able to help

Jeff

• ###### 6. Re: Top N for labels

Alex,