Pivot Table: Count number of column values within each unique sub_class expressed by class

filtrator

New Member
Joined
Jan 28, 2010
Messages
11
Hi Mr. Excel,

I need some Excel Pivot Table help, I'm not quite sure how to express this question in technically appropriate language so I've create the below illustration.

Considering the below table, is there an elegant way to count (not sum) using a pivot table, the number of seeded foods ('food_seeded') in each food_class for every unique food_sub_class?


food_classfood_sub_classfood_seededunique_food_sub_class
fruitgranny smith appleseeded1
fruitgranny smith appleseedless0
fruitmacintosh appleseeded1
fruitmacintosh appleseedless0
fruitgranny smith applenull0
fruitmacintosh applenull0
breadryeseeded1
breadryeseedless0
breadryenull0
breadsourdoughnull1
vegetablecarrotseeded1
vegetablecarrotseedless0
vegetablecarrotnull0
fruitpearseeded1
fruitpearnull0
fruittomatoseeded1
fruittomatoseedless0
vegetableeggplantnull1
fruitdelicious appleseeded1
fruitbakersfield appleseedless1
fruitbakersfield applenull0
fruitnew york appleseedless1

<tbody>
</tbody>


Thank-you!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi filtrator,

If I'm understanding your objective, this is one way...

Create a PivotTable using your source data.
In the PivotTable field list, drag the food_sub_class field into the Row Labels area.

Next hold the Ctrl key down and drag the food_sub_class field again, but this time drop it into the Values (or Datafield) area. The field should automatically be renamed to "Count of food_sub_class".

The counts displayed reflect the total count of all records for each unique food_sub_class. The last step is to filter the report to just show the count for the records that have "seeded" in the food_seeded field.

One way to do that would be to place the food_seeded field in the Report Filters area of the PivotTable field list. Then filter to just show "seeded".
 
Upvote 0
Thanks a million for the response Jerry,

Apologies; I don't think I worded my question succinctly enough -- I think I need to go one step beyond what you've illustrated.

I want to know for each food_class:


  • Fruit
  • Vegetable
  • Bread

The total count of each food_seeded value:

  • Seeded
  • Seedless
  • Null

Belonging to each unique food_sub_class:


  • Bakersfield Apple

  • Carrot

  • Delicious Apple

  • Eggplant

  • Fuji Apple

  • Granny Smith Apple

  • Macintosh Apple

  • New York Apple

  • Pear

  • Rye

  • Sourdough

  • Tomato

<colgroup>
</colgroup><tbody>
</tbody>

Would something like a Count formula applied to a Calculated Field nested inside a Pivot be possible?
 
Upvote 0
To be even more succinct -- I want to know if each unique food_sub_class contains a match against each food_seeded value. I'm dealing with a document with thousands of lines, so this fruit and vegetable illustration is more a summary of the logic that I need to summarize.
 
Upvote 0
You can do that without the use of calculated fields.

Create a PivotTable using your source data.

In the PivotTable field list, drag the food_class field into the Row Labels area.

In the PivotTable field list, drag the food_sub_class field into the Row Labels area.

Next hold the Ctrl key down and drag the food_sub_class field again, but this time drop it into the Values (or Datafield) area. The field should automatically be renamed to "Count of food_sub_class".

In the PivotTable field list, drag the food_seeded field into the Column Labels area.
 
Upvote 0
Hi Jerry,

I've created an example of what I'd like to summarize more elegantly -- how best to attach it?

Best,
 
Upvote 0
A screen shot is preferred so others can benefit without downloading. You can upload an image or excel file to a sharing site and post a link.
 
Upvote 0
Can you explain which parts of that image represent your desired result?

I'd like to understand if there's a more elegant way to summarize the top pivot table (G2:H6) and its associated formulas (I2:N6) in one pivot table that nests the counts of the formulas.

Formulas are currently counting the number of food_seeded attributes in columns I, J, K for the below food_class pivot, filtered by food_class below.
 
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,309
Members
449,080
Latest member
jmsotelo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top