4 Replies Latest reply on Apr 3, 2018 9:30 AM by Wendy Weber

# Comparison of data on different rows to find Percentages

How to do a comparison of data by Employee ID for 2 different rows? I want to compare the first 2 rows for each employee where the flag =1 for the same employee with the same food item selected.   So for this scenario it would be 2 out of 5 people met this criteria.

Employee #4 and employee #5 have their flag =1 for the same food item so 2 out of 5 employees or 40% of the employees prefer the same food now and later since Employee #4 selected Hamburgers for both choices and Employee #5 selected Ice cream for both choices.

 Employee  ID Question- when do  you Prefer this? Ice Cream Pizza Hamburger Fries 1 Now? 1 Later? 1 2 Now? 1 Later? 1 3 Now? 1 Later? 1 4 Now? 1 Later? 1 5 Now? 1 Later? 1
• ###### 1. Re: Comparison of data on different rows to find Percentages

You need two Calculations as below to get This after you pivot your foods and get 2 new columns, one for food and other as value which is 1 or blank in ur case:

Divide Countd of First Calc which is 2 by COUNTD of Employee ID which is 5 to get 40%

If it Helps, Pl mark it Helpful and CORRECT to close Thread.

Thanks

Deepak

1 of 1 people found this helpful
• ###### 2. Re: Comparison of data on different rows to find Percentages

Deepak,

This worked perfectly until I added 2 more questions.  I added a filter to only include the first 2 question which is now and later but the results are inaccurate.

I attached the Tableau workbook for you to take a look.

• ###### 3. Re: Comparison of data on different rows to find Percentages

That is Something else you are asking, it would be demanding another logic as I see it. You need to Close the present thread and Create another one To Answer your second question. Please close this thread and ask new question .
Thanks

Deepak

1 of 1 people found this helpful
• ###### 4. Re: Comparison of data on different rows to find Percentages

Thanks Deepak!   I will post the new question now.