Pivot Table Query/Confirmation

Arts

Well-known Member
Joined
Sep 28, 2007
Messages
765
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all

I have a feeling the answer the is no but was wondering if the below was possible within a pivot table?

Would it be possible to get the average based on the number of entries based on a field.

So for "Project A" would I be able to attain the average of 46 as this has five entries under Employee and then average for Project B would be 43.5 as this has two employees assigned to it etc. I have tried various setting within the value field but to no avail so hoping I may have missed something in order to give me what I need.

Project NameEmployeeSumDesired Outcome
Project ASimon A
36​
36​
Simon B
62​
62​
Simon C
32​
32​
Simon D
55​
55​
Simon E
45​
45​
Project A Total
230​
46
Project BSally A
55​
55​
Sally B
32​
32​
Project B Total
87​
43.5
Project CTom A
42​
42​
Tom B
45​
45​
Tom C
56​
56​
Tom D
63​
63​
Project C Total
206​
51.5


Thanks as always!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
1701175419687.png

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Removed Columns" = Table.RemoveColumns(Source,{"Column1"}),
    #"Filled Down" = Table.FillDown(#"Removed Columns",{"Project Name"}),
    #"Removed Columns1" = Table.RemoveColumns(#"Filled Down",{"Employee"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Removed Columns1", "Sum", Splitter.SplitTextByDelimiter("", QuoteStyle.Csv), {"Sum.1", "Sum.2"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Sum.1", Int64.Type}, {"Sum.2", type text}}),
    #"Removed Columns2" = Table.RemoveColumns(#"Changed Type",{"Sum.2"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns2", {"Project Name"}, {{"Count", each Table.RowCount(Table.Distinct(_)), Int64.Type}, {"SumT", each List.Sum([Sum.1]), type nullable number}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Average", each [SumT]/[Count])
in
    #"Added Custom"
 
Upvote 0
Thanks for this Kerry

How would I incorporate this into my file ? I see it says Power Query but I have never used this. if you could provide me steps or any insights via links that would be most appreciated as this seems to give me what I need.
 
Upvote 0
You can also do it in the pivot table using Power Pivot, but we'd need some sample data.
 
Upvote 0
Is this what you wanted?
Book3
EFG
1Row LabelsSum of SumAverage of Sum2
2Project A
3Simon A3636
4Simon B6262
5Simon C3232
6Simon D5555
7Simon E4545
8Project A Total23046
9Project B
10Sally A5555
11Sally B3232
12Project B Total8743.5
13Project C
14Tom A4242
15Tom B4545
16Tom C5656
17Tom D6363
18Project C Total20651.5
Sheet1


1701182434731.png
 
Upvote 0
Hey Rory

Is the below enough ? (I've naturally simplified the data to hide project names/employees but essentially the data would be setup as below )

EmployeeProject NameProject IDSeptemberOctoberNovemberCost Centre
Simon AProject AA-001
64​
36​
41​
BA001
Simon BProject AA-001
26​
62​
17​
BA001
Simon CProject AA-001
29​
32​
30​
BA001
Simon DProject AA-001
76​
55​
42​
BA001
Simon EProject AA-001
34​
45​
42​
BA001
Sally AProject BB-001
38​
55​
40​
BB001
Sally BProject BB-001
68​
32​
42​
BB001
Tom AProject CC-001
19​
42​
52​
BC001
Tom BProject CC-001
47​
45​
45​
BC001
Tom CProject CC-001
28​
56​
66​
BC001
Tom DProject CC-001
31​
63​
45​
BC001
Ali AProject DD-001
26​
24​
19​
BD001
Ali BProject DD-001
53​
18​
60​
BD001
Ali CProject DD-001
25​
32​
48​
BD001
Ali DProject DD-001
15​
42​
31​
BD001
 
Upvote 0
@Kerry

Yes! Thank you that's what I'm after but when I do this with my results I seem to get a different set of averages. I'll try and post some non sensitive data to show as to what I'm getting
 
Last edited:
Upvote 0
I have figured out why I am getting differing numbers when an averages are applied, Project 3 should show an average of 105 but the first entry Mike A has two entries assigned to that project. One is 126 and the other is 0. This is seen as two entries so is taking the average of him individually and not the average of the number of employees assigned to that project from the pivot (if that makes sense). So in short my initial question can a pivot take the average of a number of employees assigned to that project within the results to get the average is leading me to think no.

PMU Project NameEmployee NameSum of AprilAverage of April
Project 1Steve A00
Steve B00
Steve C00
Steve D00
Steve E144.666666667
Project 1 Total141.555555556
Project 2Alan A52.552.5
Project 2 Total52.552.5
Project 3Mike A12663
Mike B12642
Mike C6331.5
Project 3 Total31545

Thank you all that took the time out to look into this and respond.
 
Upvote 0
Hey Rory

Is the below enough ? (I've naturally simplified the data to hide project names/employees but essentially the data would be setup as below )
Ugh, I hate data like that. It's already partially summarised which makes it a pain to work with. I'd suggest using both Power Query (to unpivot the values columns into 2 columns - one for month and one for value), then load that into the data model so that you can create measures for the sum and averages. I'll post some samples when I have a bit more time.
 
Upvote 0
Thanks Rory

But please don't put to much time into it, I've got a slight work around to work out the average using this formula (basically summing the Project Total's within the pivot) =IF(RIGHT(D26,5)="Total",IF(AND(D26<>""),AVERAGEIF($C$7:$C$1200,C25,$L$7:$L$1200),""),"")

Also as a side note I'm not particularly familiar with Power Query but will do a bit of a read up on it now.
 
Upvote 0

Forum statistics

Threads
1,215,107
Messages
6,123,126
Members
449,097
Latest member
mlckr

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