Top Category


The Top Category expression shortcut is used to quickly visualize a winning category in a categorizing visualization. For example, it can be useful for coloring a map chart with winning political parties or products.

Example:

Below is a feature layer map showing the different regions in Sweden. It is colored by the top category political party, based on the number of votes that each party got in that region.

esc_top_category_example.png

Expression:

UniqueConcatenate(If(Max(Sum([Votes]) OVER (Intersect([Party]))) OVER (Intersect())=Sum([Votes]) OVER (Intersect([Party])),[Party],null))

The inner aggregation is what is calculated first: in this example it is the sum of votes per party. The number of votes is split by region as defined by the categorical axes in the visualization only (handled by the empty Intersect() statement). Then, the party with the max number of votes is found, and if the smeared number of votes value for a row equals the max number of votes, the name of that party is sent along to the next step, otherwise the result is null, since parties with a sum(Votes) lower than max are not interesting. All parties that have the max number of votes are concatenated to a list so that ties between several parties with the max number of votes are handled. In order to avoid the same party name being shown more than once, it is the unique concatenate function that is applied to the result.

See also Aggregations in Expressions for more information about how inner aggregations are handled.

Column Selector Controls in Expanded Mode:

esc_top_category_column_selector.png

Option

Description

Aggregation

This is where you select the Top Category aggregation.

Display name

Allows you to specify a different display name, instead of the default "Top Category ([Category Column Name] for InnerAggregation([Column Name]))".

Category column

Allows you to specify the categorical column to find the winner in.

Inner aggregation

Allows you to specify the aggregation method of the inner aggregation where you want to find the winner. The default aggregation is sum.

See also:

Expression Shortcuts Overview

Aggregations Overview

OVER in Custom Expressions

Using Expressions on Aggregated Data (the THEN Keyword)