This seems like something that should be so simple, but I can't figure it out this morning. I've even had my coffee. I am returning four fields from a WebFOCUS query: SHIPWEEK, Ship Date, Part Numberand Quantity (QTY). I set up the query so that it pulls 365 days of records when the workbook opens. I have then summarized the data into a Pivot Table. The Pivot Table simply shows SHIPWEEK as a row with two VALUES: Count of QTY and Sum of QTY. This all works fine.
What I want beyond this, however, is to calculate for the range of the returned results the average weekly count and standard deviation. I can do this simply by using the AVERAGE() and STDEV() functions and pointing to the two VALUES ranges in the Pivot Table. That will work once. But I'd like to not have to manually adjust the range for these formulas each time I run the query. Theoretically, there will be the same number of weeks in 365 days of data, but that may not always be the case. If the number of rows in the Pivot Table changes, then it might skew my results.
Surely there is a way to do this in the Pivot Table itself? Pivot Table offers a "Grand Total" option, which will sum all of the records, but I don't know how to do the equivalent of "Grand Total" for average or Standard Deviation.
If not in the Pivot Table, then dynamically outside of the Pivot Table without requiring manual range updates each time?
I think (though I'm not sure) that this answers your question. In the PivotTable Builder, select the value you are trying to calculate, and click on the detail button (so in the image below, the little "i" next to the appropriate item in "values". Then select the function you want instead.
Related
I have a calculated field in a pivot table returning the running total of my period totals (Ending balance of each period). When my period Field in entirely collapsed, it looks great, but when I expand a period to look at individual transactions the calculated field is on all of those rows as well.
I'm ideally looking to see if anyone has a purely pivot settings solution.
I've tried using VBA to clear the contents when the table is updated but run into error 1004 - use field list option to modify pivot table.
I'm currently making the range text white by finding all the required cells then Rng.font.TintAndShade = 0.
I'd also like to keep this WB ".xlsx" format so it's easier for me to send to coworkers.
Pivot Collapsed:
Pivot Expanded:
Calculated field settings:
Future solution thanks to #JosWoolley:
Enable Power Pivot
Import table into the Data Model
Use DAX formulas to generate the expected result
I am starting to use the Excel data model and pivot tables. I am struggling to produce the results I want for budgeting type tables. Given my very simplified example:
I had no problem creating the pivot table with sums for each category of income and expense. I used a slicer for year. The problems I have are with the Totals.
I want a column grand total which is the sum of income - the sum of expense, but it appears that pivot tables always use the same formula for every value in the table regardless of it being in a totals row or column.
In addition to the Total for the year for each row, I would like a monthly average column.
Both these seem to me like obvious things to do with a pivot table. The pivot table makes aggregating all the transactions from the journal trivial. I feel like I must be missing something, because I can't find a way to do something so obviously useful.
Basically, I have a set of data, with the following columns: date, price, daily price change and % change, the former two calculated using pivot table field list menu. I want to calculate the cumulative daily change over the period of time, in a next column. As it is a pivot table, it has absolute references and I cannot simply add previous day's change to a today's change one by one, due to a large data set. What is the most efficient way to do it? Thank you.
Go to pivot table option tab which appears when you select any cell in the pivot table range. The click on the drop down menu Option and deselect Generate GetPivotData.
After this, you can use the formulas as normal.
You can add additional column in the main sheet as "cumulative change". The new column can have the cumulative value and you can use summation formula for this.
Then you can take this value in pivot table for further analysis.
Take the help of Vlookup also.
You can follow the steps in the video below for detail pivot analysis as per your need.
https://www.youtube.com/watch?v=vzd7RUGloXM
https://www.youtube.com/watch?v=wsCxOmsMq6k
I'm sure this is simple, but how do I get a pivot table to display an average for a calculated sum of fields? In the simplified example, I've filtered out fund x1, and the pivot table is showing the sums of the remaining funds per person. Now how do I get an average by person (so, manually calculated, 3300/3)?
I tried using a calculated field, but cannot figure out how it will work because the denominator will change based on how many people will have the funds I'm filtering on. If I use the averaging inside the calculated field it goes back to averaging the funds.
I tried putting the calculation outside the pivot table, and this works, but of course as I filter, my calculated field is no longer adjacent to the pivot table data, instead just floating off on the worksheet by itself.
TIA.
Per request here is the field list - if I try adding an "average of amount" to the value box it averages the fund amounts, instead of the fund amount per person. :
Here is a working solution:
Firstly you should install or enable Power Pivot. Quoting Microsoft:
Power Pivot is an Excel add-in you can use to perform powerful data
analysis and create sophisticated data models.
https://support.office.com/en-us/article/Power-Pivot-Powerful-data-analysis-and-data-modeling-in-Excel-a9c2c6e2-cc49-4976-a7d7-40896795d045?ui=en-US&rs=en-US&ad=US
In newer Excel versions Power Pivot is already installed and you can enable it by going to:
File > Options > Advanced > Data > Enable Data Analysis add-ins: Power Pivot, Power View, and Power Map
Alright, so you have Power Pivot now and you can see Power Pivot tab. Please follow the steps below:
Select your data and click add to “data model” icon on Power Pivot tab.
In Power Pivot window add column which will count distinct number of
persons in the data. =DISTINCTCOUNT([person]) name it for example
“DistPersNo”. This is crucial step – Power Pivot enables you to
count unique values in selected column.
Add another column with formula =[amount]/[DistPersNo] name it
“PersonAverages”.
In Power Pivot window click PivotTable and add new pivot table to
your worksheet.
In Pivot Table add 'persons' to rows and 'amount' to values. Now, if you add 'PersonAverages' to values (sum of it) and filter out fund 'x1' you will achieve desired result i.e. value of 1100.
Hope that helps.
I would add a helper column in column D to count unique customers.
Sort your data by person
In column D2 put =IF(A2=A1, 1, 0) and call the column UniqueCust
Copy formula down your dataset for all rows
Add the column to your pivot
Create a formula in your pivot table called Avg per Cust =Value/UniqueCust
This will flag each row in your data with a 1 if it is the first time a name appears in the column or zero otherwise. The pivot table calculation will sum up the total value and divide by the total unique customers.
I'm assuming that you want the value to come in any pivot table and not in a cell calculated outside the pivot table as a formula.
As a workaround you can use another pivot table, which takes the input as the original pivot table to find the average.
pivot tables
The second pivot table has data source as- E3:F5 or till whatever row you require.
You'll have to refresh all so that the second pivot table reflects any changes in the filter of first pivot table.
I've hidden (or you can filter it out) the grand total in the first pivot table so that the average gives the average of the sum of the amounts.
Since you didn't mention how you are using the data, I will give a couple of options that could work.
If you are the only user of the data or if someone else using the data is pivot table savvy you can use the following field list setups to switch data usage:
Sort by Fund (Note the Fund and Person in the Row labels section)
and Sort by Person (Note the reversed position of Fund and Person in the Row labels section)
To simplify the data, you can always minimize the main fields.
If you are distributing the pivot table to other people who aren't able or willing to modify the pivot table data, I would recommend setting up two separate pivot tables (using the same data source) with the same setups that I showed above.
Click the pivot table to bring up the field list.
In the Values section where it says "Sum of Amount" click the drop down.
Click "Value Field Settings" and choose average from the list in the pop-up.
In Excel Pivot table report there is possibility for user intervention by inserting "Calculated Field" so that user can further manipulate the report. This seems like best approach compared to using formula on Pivot table data, outside the Pivot table, for many obvious reasons.
"Calculated Field" dialog, looks like this:
and while it's easy to do calculation between available variables (as shown in screenshot) I can't find how to reference range of values for any of available variables.
For example, if for some reason I want to center the data in range A1:A100 I'd use = A1 - AVERAGE(A1:A100) and fill all rows in regular Excel table. But for Pivot table, if I use "Calculated Field" dialog and add new variable with formula: = 'Actual Sales' - AVERAGE('Actual Sales') I get 0 as output.
So my question is how can I reference whole range for 'Actual Sales' variable in "Calculated Field" dialog, so that AVERAGE() will return the average of all targeted cells ?
I'll post this comment as answer, as I'm confident enough that what I asked is not possible.
I) Couple of similar questions trying to do the same, without success:
Pivot Calculated formula: SUM(Field1)/AVG(Field2)
Excel Pivot Table Calculated Field
II) This article: Excel Pivot Table Calculated Field for example lists many restrictions of Calculated Field:
For calculated fields, the individual amounts in the other fields are summed, and then the calculation is performed on the total amount.
Calculated field formulas cannot refer to the pivot table totals or subtotals
Calculated field formulas cannot refer to worksheet cells by address or by name.
Sum is the only function available for a calculated field.
Calculated fields are not available in an OLAP-based pivot table.
III) There is tiny limited possibility to use AVERAGE() and similar function for a range of cells, but that applies only if Pivot table doesn't have grouped cells, which allows listing the cells as items in new group (right to "Fileds" listbox in above screenshot) and then user can calculate AVERAGE(), referencing explicitly every item (cell), from Items listbox, as argument. Maybe it's better explained here: Calculate values in a PivotTable report
For my Pivot table it wasn't applicable because my range wasn't small enough, this option to be sane choice.
Some of it is possible, specifically accessing subtotals:
"In Excel 2010+, you can right-click on the values and select Show Values As –> % of Parent Row Total." (or % of Parent Column Total)
And make sure the field in question is a number field that can be summed, it does not work for text fields for which only count is normally informative.
Source: http://datapigtechnologies.com/blog/index.php/excel-2010-pivottable-subtotals/
Thank you for planting a seed, Cel! I've been struggling with this for hours, finally got it. I was counting a text field, oops, calculation failed.
Created 2 helper columns in my raw data, each resulting in 1 if condition met, 0 if not. Then pulled each into a pivot column, mine are called, "Inbd" (for Inbound), "Back", where "Back" is a return to sending facility, so in reality the total is one trip, not 2 trips, i.e., back is a subset of inbound and not every inbd has a back (obviously). Trying to calculate in the pivot table so I can sort on the field the rate of back to inbound for each sending facility.
For my calculated field I used: =IFERROR(IF(Pvt_Back>0,Pvt_Back/Pvt_Inbd,0),0)
So: if we sent back to sending some number of times greater than 0, divide Back/Inbd to give me a rate; if equal to 0, then 0; if Inbd = 0, then 0 to avoid Div/0 error.
Thanks again!! :)
Pivot table Excel2007- average to exclude zeros
=sum(XX:XX)/count if(XX:XX, ">0")
Invoice USD
Qty Rate(count) Value (sum)
300 0.000 000.000
1000 0.385 385.000
Average Rate Count should Exclude 0.000 rate