4 Replies Latest reply on Aug 2, 2016 10:25 AM by Lindsay O'Keefe

# Percentage of Two Columns

Hi,

On the attached packaged workbook, on the "YTD Channel Sources" tab I have two columns that I need to divide and get the percentage in the "Completions vs. Visits" column.

Completions vs. Visits = Goal Completions / Visits

For example, the Completions vs. Visits column for "Referral" would be:

136150/535877 = 25% not the 50.88% that's populating there.

• ###### 1. Re: Percentage of Two Columns

Create a new calculated field: SUM([Goal Completions])/SUM([Visits])

That should fix it.

1 of 1 people found this helpful
• ###### 2. Re: Percentage of Two Columns

Hi Lindsay,

Andrew got this one right. Quick and Easy fix for you.

The reason why its working is fairly simply as well. Order of operations matters!

Notice that the Completion v Visits field you are using says SUM() ? This is because you are finding the quotient for each row and then summing the result of all the underlying rows. We first sum the entire column for both and then divide. Easier to see why we do this in excel because in excel we are presented with looking at all the underyling data all the time and it's more obvious.

Your field when you use it after you fix it with Andrews correct fix will use AGG() instead as an indicator that it is pre-aggregated. If you edited your field and didn't create a new one you will notice this goes red. Never fear. Just drag it off and bring it back. This is because tableau is now trying to SUM() an aggregate and it's not allowed.

Best Regards,

Carl Slifer

InterWorks

1 of 1 people found this helpful
• ###### 3. Re: Percentage of Two Columns

Hi Lindsay,

Carl and Andrew are spot on. Here is a video on on the topic: Aggregation, Granularity, and Ratio Calculations

-Brian

1 of 1 people found this helpful
• ###### 4. Re: Percentage of Two Columns

That worked! Thank you!