2 Replies Latest reply on May 15, 2012 9:07 AM by Laurent Moffroid

# Number of Employees in 2010: how to ask Tableau?

Hi,

I am stuck with the following issue:

I would like to filter all companies in my db that have a certain number of employees in 2010 but yet be able to see all other years.

So I would like to filter the companies according to their number of employees in 2010 and look at their 10 year trend.

How could I create this 'Number of Employees in 2010' filter?

Thank you very much for your help,

Laurent

• ###### 1. Re: Number of Employees in 2010: how to ask Tableau?

Hi Laurent

This is possible, although there must be an easier way than they way I've done it. I had to create a couple of calculated fields and a parameter to achieve the desired result but don't have the time right now to see if there's a better way to do this. Perhaps some of the experts on this forum will supply a neater solution.

Firstly I create a calculated field to count the number of employees in 2010. I had to create this as a Table Calculation as I believe filtering based on a table calc filters only the results and not the source data. I called the field 2010EmployeeCount and the formula I used is: WINDOW_SUM(SUM(IF [Year] = 2010 THEN [Employees] END)).

Next I created a simple parameter, MinEmployee2010, so the user can enter the minimum employees required in 2010 for the company to appear in the report.

The final step is to create a calculated field, 2010EmployeeFilter, to be the filter combining the calculated field and the parameter.  This is IF [2010EmployeeCount] >= [MinEmployees2010] THEN 1 ELSE 0 END.

Drag this pill to the Filters shelf and set the value to be a minimum of 1 and it will only display those companies with a 2010 employee count greater than or equal to the number selected in the parameter.

I've attached the twbx file for reference. Hope it works for you. I've also written a blog post showing how a table calculation filters only the results and not the underlying dataset.

Andrew

Message was edited by: Andrew Watson

• ###### 2. Re: Number of Employees in 2010: how to ask Tableau?

Hi Andrew,

Many thanks for your help - I was slower to implement it than you were to create it

And thanks also for being so reactive!

Cheers

Laurent