ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Adding a calculated field to a pivot table (https://www.excelbanter.com/excel-worksheet-functions/179309-adding-calculated-field-pivot-table.html)

DanL

Adding a calculated field to a pivot table
 
I have a pivot table that includes these fields:
1. A count of "Traffic types" (which are text)
2. A count of "Sales Dollars" (which is in currency)

I want to add a calculated field that will take #2 above and divide it by #1.

When I create such a field (= 'Sale '/ 'Traffic Type') I get a divide by
zero error, even though fields are populated. I am trying to get to a
"closing %". Can anyone advise me as to where I am making my error?
Thanks!
Dan

Sean Timmons

Adding a calculated field to a pivot table
 
Unfortunately, calculated fields caculate off the original table, not the
pivot table.

An alternate option is to calculate outside the table. So, assuming you have
your headers in A3 through C3, and each subject takes up to rows, Try going
to D5 and typing C5/C4. Highlight D4 to D5, copy, paste down to the bottom.

"DanL" wrote:

I have a pivot table that includes these fields:
1. A count of "Traffic types" (which are text)
2. A count of "Sales Dollars" (which is in currency)

I want to add a calculated field that will take #2 above and divide it by #1.

When I create such a field (= 'Sale '/ 'Traffic Type') I get a divide by
zero error, even though fields are populated. I am trying to get to a
"closing %". Can anyone advise me as to where I am making my error?
Thanks!
Dan


DanL

Adding a calculated field to a pivot table
 
Sean:
Thanks for the response, I appreciate it!! When I go to the source table
(not the pivot table, correct?) to add the formula you suggest, that would
now attempt to divide a number by text, would it not? When I did that, it
still returns a 'name' error.

Did I read your instruction correctly?

"Sean Timmons" wrote:

Unfortunately, calculated fields caculate off the original table, not the
pivot table.

An alternate option is to calculate outside the table. So, assuming you have
your headers in A3 through C3, and each subject takes up to rows, Try going
to D5 and typing C5/C4. Highlight D4 to D5, copy, paste down to the bottom.

"DanL" wrote:

I have a pivot table that includes these fields:
1. A count of "Traffic types" (which are text)
2. A count of "Sales Dollars" (which is in currency)

I want to add a calculated field that will take #2 above and divide it by #1.

When I create such a field (= 'Sale '/ 'Traffic Type') I get a divide by
zero error, even though fields are populated. I am trying to get to a
"closing %". Can anyone advise me as to where I am making my error?
Thanks!
Dan


Debra Dalgleish

Adding a calculated field to a pivot table
 
The calculated fields always use the Sum of the pivot fields, even if
you're using another summary function, such as Count. For text fields,
the sum will always be zero, so that's why the calculation isn't working
the way you want it to.

In your source table, you can add two columns -- one to count the
traffic types (TraffCount), and one to count the sales dollars
(SaleCount). You could manually enter a 1 in each column, or use a
formula to calculate the count.

For example, if the Sales Dollars are entered in column G:
=IF(G2=0,0,1)
Do the same for Traffic Types, or if there will always be a Traffic Type
entered, just type a 1 in the Traffic Count column.

Then, in the pivot table, create a calculated field with the formula:
=SaleCount/TraffCount
and format it as percentage.

DanL wrote:
I have a pivot table that includes these fields:
1. A count of "Traffic types" (which are text)
2. A count of "Sales Dollars" (which is in currency)

I want to add a calculated field that will take #2 above and divide it by #1.

When I create such a field (= 'Sale '/ 'Traffic Type') I get a divide by
zero error, even though fields are populated. I am trying to get to a
"closing %". Can anyone advise me as to where I am making my error?
Thanks!
Dan



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html


DanL

Adding a calculated field to a pivot table
 
Debra:
That did it and thank you for the great tip!! I have about an hour into this
trying all kinds of formulas and convoluted thinking and your simple solution
did the trick.
Appreciatively,
Dan

"Debra Dalgleish" wrote:

The calculated fields always use the Sum of the pivot fields, even if
you're using another summary function, such as Count. For text fields,
the sum will always be zero, so that's why the calculation isn't working
the way you want it to.

In your source table, you can add two columns -- one to count the
traffic types (TraffCount), and one to count the sales dollars
(SaleCount). You could manually enter a 1 in each column, or use a
formula to calculate the count.

For example, if the Sales Dollars are entered in column G:
=IF(G2=0,0,1)
Do the same for Traffic Types, or if there will always be a Traffic Type
entered, just type a 1 in the Traffic Count column.

Then, in the pivot table, create a calculated field with the formula:
=SaleCount/TraffCount
and format it as percentage.

DanL wrote:
I have a pivot table that includes these fields:
1. A count of "Traffic types" (which are text)
2. A count of "Sales Dollars" (which is in currency)

I want to add a calculated field that will take #2 above and divide it by #1.

When I create such a field (= 'Sale '/ 'Traffic Type') I get a divide by
zero error, even though fields are populated. I am trying to get to a
"closing %". Can anyone advise me as to where I am making my error?
Thanks!
Dan



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html




All times are GMT +1. The time now is 02:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com