3 Replies Latest reply on Feb 1, 2017 8:35 AM by Allen Dsouza

# How to find count of employees in Both but with a condition. Any better way to do what I have achieved so far

Hi,

I am new to Tableau; I have the logic and the ideas but cant figure how to do it in Tableau.

I have 4 columns

Emp id          Food item          Burger king hrs          Mc Donalds hrs

 1 10 6 2 1 11 0 3 2 12 4 0 3 13 3 4 3 14 0 3 4 11 0 2 4 12 0 4 5 11 0 5 6 11 0 4 7 11 4 0 7 12 5 0 8 11 3 0 8 13 0 9 9 11 0 9 9 12 0 9

I want to find the number of employees in both, only in Burger King, only in McDonald's  (I was able to find the count in tableau using simple calculated fields)

Now I want to find out the number of employees in Both but where McDonald's had a food item that Burger king didn't (Logic : Find employees in both and where Burger King hrs = 0).

I was thinking of using the emp ids found in worksheet 3 in a new worksheet. Can this be done or Is there any better way to do this?

• ###### 1. Re: Want to find count in both, count in only 1 group and count in both with better group

Hi Allen!

I hope this is the solution you are looking for. If not, do share the details of the expected output in numbers to get better understanding.

Check the attachmet of Tableau workbook in 10.1 Version.

Regards,

Sireesha.

• ###### 2. Re: Want to find count in both, count in only 1 group and count in both with better group

Hi Sireesha,

1. Find count of employees in Burger king only ---Found (worksheet 1)

2.  Find count of employees in McDonalds only ---Found (worksheet 2)

3. Find employees in both------------------------------Found (worksheet 3)

So 3 employees were foudn in both Emp ids : 1 , 3, 8

Now I want to find the count of employees found in both but where McDonald had a food item.

So employees 1, 3 ,8 are found in both but I want only the highlighted employees that have Burger king hrs= 0 against them.

Also can you reattach your workbook; I wasnt able to open it.

• ###### 3. Re: How to find count of employees in Both but with a condition. Any better way to do what I have achieved so far

Hi,

The solution is to create sets on Emp id. Right Click on Emp id and Create sets.

In the condition tab, add formula

For Emp id in both:

SUM[(Burger king hrs)]> 0

AND

SUM[(Mc Donalds hrs)]>0

Once the set is created, drag it to filters. Create another filter for Burger king hrs= 0 and drag it to filters.

Drag Emp id to text area and choose measure to count distinct. Drag Emp id to Rows

This will give you all the employees that satisfy Burger king hrs= 0 for employees found in both.

Now to find total count of these employees , click on Analysis >> Totals >>Show Column grand totals.

2 of 2 people found this helpful