3 Replies Latest reply on Sep 1, 2016 9:03 AM by chris.moore.11

# Limit graphs to show only top models based on aggregated attribute across time

Hello everyone,

In this chart that I'm making, I'm trying to limit the graphs to show only top models. However I'm having difficulty understanding why Tableau behaves the way it does.

I've attached a sample workbook.

The viz shows by car models the history as well as forecasts from sales team and the system generated. The difference between the sales and systems forecast is called the gap.

I need to limit the viz to show only 4 car models with the largest gap (defined as the absolute value of difference across 18 months between total sales forecast vs total system forecast)

I made a calculated field called "Abs Gap - by Region by Model by Division" using LOD expression, which produces the gap by each model. This is shown in Sheet1

The thing I cannot figure out is this:

- When I bring "Abs Gap - by Region by Model by Division" to filter, and do a RANK table calculation, and then filter to <= 3, it seems to work - the graph is now limited to just showing the top 3 models. This is shown in Sheet 2

- But (in Sheet3) if I filter to <= 4, the charts shown are incomplete. Eg: for model 3308i and 2262i, only the first part of the history is shown, and none of the forecast portions are shown.

What is causing Tableau to show only a portion of these charts?

And how can I get Tableau to just show the top 4 charts based on largest gaps?

• ###### 1. Re: Limit graphs to show only top models based on aggregated attribute across time

Hi, its because your rank function only gives a rank where there is data. So the fourth model starts at a later date, so it doesn't have a rank until a later date. The brown line in this workbook is your rank function, hopefully that illustrates why filtering based on that gets weird.

An easy way to get a top N, is to create a set. See the filter "Set 1" on the second sheet of the attached. Also, see here... Create Sets for Top N and Others | Tableau Software

• ###### 2. Re: Limit graphs to show only top models based on aggregated attribute across time

Chris. do find that the use of set as you mentioned is workable solution. Thanks!

Regarding the part you mentioned about rank function only gives a rank where is data...So you mean that models 3017c and 3308i is not ranked? But if so, why does it show up in the chart?

Further, is there any way we can edit it such that the "Rank" can be used as a filter directly?

Thanks again.

• ###### 3. Re: Limit graphs to show only top models based on aggregated attribute across time

There will only be a rank for the the months that there is data.

So for example, 3017c doesnt have a data until august so 3308i actually gets ranked 4th until august. In the picture below the brown is the rank. See how it goes up slightly from 4 to 5 once the data exists for the 3017i?

I'm not sure about how to work around this using the table calcs. Theres probably a way but it could be a little complicated.

1 of 1 people found this helpful