In Tableau how do I use RANK to calculate an "OTHER" field?

Viewed 141

I'm new to Tableau so this may be an easy question about computations using RANK. I can't find any tableau HELP or other stack-overflow answer to this. Maybe this is a GROUP question. Maybe it's about OTHER.

I have a data set of 160 countries ( rows ) with a field for jetfuel consumption for each country.

I just want to make a bar chart like the attached image showing the 20 highest fuel-consumption countries by name ranked by jetfuel_consumption ( I can do that much) AND an 21st row computed country name titled "Rest of world" summing the remaining 140 countries together as if it were just another country like the bottom of this model .What I want

I have a working valid computed field labelled "myrank" = RANK(AVG([Jetfuel Consumption]),'desc') My thought was to simply calculate a new text field that would equal the country name for rank < 21 and then be the string "Rest of World" otherwise. Such as:

IF ( [therank] < 11 ) [Country] ELSE "Rest of World" END

But that is not valid for an unspecified reason. I know I'm confused already about how to just specify the value of a field without something like SUM or AVG or AGG wrapping it, but this is a larger question.

What's the right way to make this view?

1 Answers

I've created simple dataset:

data

And I want to group TOP 3 countries by Consumption. To do it I should create a set (click on Country in Dimension) and select TOP 3 By SUM(Cosumption): create a set

Then create a calculated field to show Countries IN Set and "Others".

calc

IF [Country Set] is a boolean expression "The country IN a set".

Drag and Drop corresponding fields and configure sort, for example: enter image description here

Sets are convenient to dynamically change, expand and customize any visualization. More detailed: https://help.tableau.com/current/pro/desktop/en-us/sortgroup_sets_topn.htm

Related