I'd like to perform the standard deviation of a specific range in a pivot table.
I tried the following formula to get the SD of the range C8:C28:
=STDEV(GETPIVOTDATA("Sum of PL DIR & CAR",$A$4,"AssetClass2","Equity US"))
It returns #DIV/0!
Do you have the correct formula?
Here is the pivot table:
Based on your image, you might be able to use something like the below, assuming there is no data below the pivot table
This will work even if additional rows are added into the pivot, i.e making it a dynamic range with OFFSET etc.
=STDEV(OFFSET($C$8,0,0,COUNTA($C:$C)-2,1))
Or you can use INDEX which is a non-volatile function:
=STDEV(INDEX($C:$C,ROW(C8)):INDEX($C:$C,COUNTA($C:$C)+1))
You may need to tweak that COUNTA($C:$C)+1 to fit your criteria but this should give you the idea.
Related
I have below an example pivot table with Countries as my columns, and Dates as my rows. The data for this pivot is based on A1:C13. Cells F1:G3 is what the user of this model can adjust. They can change the country and/or the date ranges.
What I am needing is a single formula to output the total of their selection. As my actual data set contains many countries, simply writing an nested IF statement won't suffice. The dataset also needs to be in pivot table - hence the GETPIVOTDATA requirement.
I've gotten about half of the way there using this formula here:
=SUM(GETPIVOTDATA("Sum of Value",$A$15,"Date",ROW(INDIRECT(F2&":"&F3)),"Country",F1:G1))
The problem here is that this formula is not dynamic for the differing date selections per country.
Can anyone assist?
You need a separate GETPIVOTDATA for each country:
=SUM(GETPIVOTDATA("Sum of Value",$A$15,"Date",ROW(INDIRECT(F2&":"&F3)),"Country",F1),GETPIVOTDATA("Sum of Value",$A$15,"Date",ROW(INDIRECT(G2&":"&G3)),"Country",G1))
The answer provided by #basic is the closest one for the original question, i.e. using GETPIVOTDATA to work out the total per given parameters.
If the calculation can be done on the original data table (Range A1:C13), then here is another solution to calculate the total.
=SUMPRODUCT((A2:A13=F1:G1)*(B2:B13>=F2:G2)*(B2:B13<=F3:G3)*(C2:C13))
In order to make the above calculation "dynamic", i.e. the calculation updates as the rows expands in the table, you can put the source data into a Structured Reference Table, give a Name to each column, such as "List_Ctry" for Column A, "List_Date" for Column B, and "List_Value" for Column C, then the range behind each name will update automatically when the source data changes. Using these names, the formula will be something like:
=SUMPRODUCT((List_Ctry=F1:G1)*(List_Date>=F2:G2)*(List_Date<=F3:G3)*List_Value)
You can also give names to the three parameters, being the range of country, range of start date, and range of end date. I will not illustrate further as if you understand the above concepts, you should be able to do this step yourself.
By using Name in the excel workbook, it will enable you to refer to the source data conveniently without the need to lay it out in your final report, so I do not understand what is the limitation here to stop you from calculating from the source data but have to work on the pivot table, as the calculations on pivot table are limited and not that intuitive.
Feel free to let me know if you have any questions :)
I am using a PivotTable, and using the GETPIVOTDATA formula to populate
data on a separate worksheet. Some days there is no data for this particular pivot table column. Is there a way I can include with my GETPIVOTDATA statement, that if it shows an error
or #REF! it will reference another cell in that pivot table. I tried an If(And) statement and it did not work.
Here is the current formula=GETPIVOTDATA("Disposition",'ACD Service Levels Pivot'!$A$3)-GETPIVOTDATA("Disposition",'ACD Service Levels Pivot'!$A$3,"Application","CallbackQueue")
The reference cell I would like for error #REF! to go to is GETPIVOTDATA("Disposition",'ACD Service Levels Pivot'!$A$3)
Thank you
#usmanhaq Thank you for the comment. My goal was to make the formula logic dependent on the pivot table. However, I created a "helper table" using iferror. In which when the pivot table does not have the available data, the helper table will show "0". I can proceed with writing the formula to look at the helper tables "0" instead of the Pivot tables "#REF!" error it throws when no data is available using GETPIVOTDATA. Thanks for leading me down the path.
I am trying to fill in my Summary Table with the data from a pivot table I have created. Within my summary table, I am trying to pull the closing number of the specified stock from the specific day. I believe the VLOOKUP function is the best way to do this, but I keep getting a #N/A. What is the proper way to write the VLOOKUP? My VLOOKUP Function looks like:
=VLOOKUP(C7,'Pivot Table'!$4:$3914,1,FALSE)
Do I need to restructure my pivot table or use an HLOOKUP?
You can use the MATCH() function in the VLOOKUP to find the correct column, but you need to look for the date first then the ticker column:
=VLOOKUP(E$6,'Pivot Table'!$5:$3914,MATCH($C7,'Pivot Table'!$4:$4,0),FALSE)
Then drag it over and down.
OR
If you want to look for the Ticker first you can use a HLOOKUP with a MATCH():
=HLOOKUP($C7,'Pivot Table'!$B:$N,MATCH(E$6,'Pivot Table'!A:A,0),FALSE)
OR
You can use INDEX() with two MATCH()
=INDEX('Pivot Table'!$A:$N,MATCH(E$6,'Pivot Table'!A:A,0),MATCH($C7,'Pivot Table'!$4:$4,0))
You may access the pivotCache directly:
Use the names of your pivot table fields either by :
1) Looking at the names of the fields in the field list
2) referring to your data table and seeing what names you use, or
3) using tabular or outline layout(instead of compact - and the field names wil come up in the rows and columns dropdowns).
Then use:
=GETPIVOTDATA("Close",'Pivot Table'!$A$4,"correctNameofDateField",E$6,"correctNameOfTickerField",$C7)
You can drag this across and down.
I want to use several GetPivotData functions, retrieving data from the same Pivot table. I want each of them to retrieve different data based on a filter value.
For instance:
Get Pivot Data for Month:January
Get Pivot Data for Month:February
Where Month is a filter on the Pivot. Is this possible using a formula?
I hope this will solve your problem. Try this workaround from Microsoft:
https://support.microsoft.com/en-us/help/287736/getpivotdata-formula-is-automatically-created-when-you-try-to-create-s
When you change the month, the value changes too. But make sure that there are no hidden items (because if not, you won't get an accurate #/data).
see the screenshot below where the Month to choose is based on a cell reference as an argument in the GETPIVOTDATA formula:
Victor,
The Pivot tables won't work like you intend to. All data that your formula shall retrieve must be visible at the same time. I suggest that you arrange for some space on your worksheet and apply the solution proposed by Scott.
NB: If you want to deal with data added month by month, for example, there is an Pivot table option to automatically add new values to the filter. Then in your formula you can use IFERROR to show blank cells when there is still no data available.
Regards,
+Daniel+
-
I have a tabular data with values as in picture. I created a pivot table in excel 2007 .How can I get count value of each up/Down for date specified. I tried to by making one column row and other as values but it would not work.
The result would be:
A better solution is to use a countif function on a second tab. something like
=COUNTIF(Sheet1!A:A,"UP")
and
=COUNTIF(Sheet1!A:A,"DOWN")
and copy it across the range of dates.
If you can format your data differently to look like this
Then the pivot table becomes easy withthe following settings