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!
 
Okay, now I'm seeing the part you are having difficulty doing. The base Excel program doesn't have a distinct count form of aggregation.
To do that you can use an intermediate table (a bit clunky), PowerPivot (an add-in for Excel 2010 and provided free with the full version of Excel 2013), or do an SQL Query using MS Query.

Would any of those be an option you want to pursue?
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I'm on a Mac using Microsoft Office 2016 for Mac -- can you advise which of the above is the most compatible option?

I haven't used MS Query however I know how to use SQL -- if I used MS Query would it mean the analysis results would be stored outside of the document?
 
Upvote 0
I don't have access to xl2016 for Mac, however I did find this article regarding how it allows queries.
https://blogs.office.com/2015/08/20/working-with-external-data-in-excel-2016-for-mac/

Speaking only from my experience with MS Query, the technique that is used is to start a blank new workbook and make an external query of your closed workbook with the data source.

Put the results of that query into a PivotTable in the new workbook. Then Move that PivotTable (Cut and Paste) it into the same workbook as the data source.

That way the PivotTable and data source can be in the same workbook. When the data is changed the Pivot can be refreshed to reflect the changes.
 
Upvote 0

Forum statistics

Threads
1,215,454
Messages
6,124,933
Members
449,195
Latest member
Stevenciu

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