independent columns in pivot table

slaytanic

New Member
Joined
Oct 5, 2017
Messages
3
Hi, I'm wondering if I can have what I need in a single pivot table?
Let's say this is the input table - players scoring against different teams from various conferences:

namevs teamvs confpts
player1team1east10
player1team1west40
player1team2east5
player1team2west25

<tbody>
</tbody>

etc

The real table has much more data than this. I would like to have a single pivot table which averages points in columns per different criteria like so:

NameAvg points totalAvg vs team1Avg vs Team2Avg vs EastAvg vs West
player12025157.522.5

<tbody>
</tbody>




If I use columns, then the second column becomes a subgroup of the first one and I don't want that. Can you point me to the possible answer. Right now I have multiple pivot tables and then paste results from 1 column next to the other pivot table but that is quite awkward. Thanks
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
I'm not sure you can put this all in one and selectively remove the subgroups, but 3-4 pivot tables next to each other works fine, why do you say it's awkward?
 
Upvote 0
A query table approach can return the desired cross tab. With SQL like
Code:
TRANSFORM AVG(pts)SELECT name
FROM (
SELECT name, [vs team], pts
FROM [YourSheetName$]
UNION ALL
SELECT name, [vs conf], pts
FROM [YourSheetName$])
GROUP BY name
PIVOT [vs team]

Assuming YourSheetName is the name of your worksheet. Use your sheet name instead or otherwise a basic (non-dynamic) defined range. So the SQL would be like such as "FROM definedname" where it currently says "FROM [YourSheetName$]"

So save the file, ALT-D-D-N and follow the wizard. Excel files, etc. If you get a message about no visible tables just acknowledge that and then choose system tables + OK to see worksheet names.
At the end of the wizard choose the option to edit in MS Query and then via the SQL icon edit the SQL to be like above. OK to enter, acknowledge any message about not being able to graphically represent etc. Via the 'open door' icon exit MS Query and create the query table. It is refreshable like a pivot table.

If you prefer a pivot table, start instead from a new workbook & use the pivot table wizard: ALT-D-P. Choose external data source at the first step and it is very similar. Change the SQL so it isn't the cross tab but simply the re-arrangement,
Code:
SELECT name, [vs team] AS [Versus], pts
FROM [YourSheetName$]
UNION ALL
SELECT name, [vs conf], pts
FROM [YourSheetName$]
The resultant worksheet containing the pivot table can be moved into your source data workbook if you want.

Another thought, if you want to identify if the data came from the 'vs team' or 'vs conf' field then just add that as a text field within the SQL.

cheers
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,613
Messages
6,125,834
Members
449,266
Latest member
davinroach

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