Why do I have to refresh Pivot Table to include all fields? - excel

Here is the scenario:
Sheet1 has 15 columns and 16,000 rows
PivotTable created in Sheet2 for all data in Sheet1
2 new columns of data added in the middle of existing columns in Sheet1. New total is 17 columns
Second PivotTable created in Sheet3 for all data in Sheet1
When I create the second PivotTable, based on all 17 columns of data, it only shows the original 15 columns as fields. I have to refresh the PivotTable to show all 17 columns.
I understand that I have to refresh an existing PivotTable after I change the source data, but if I make a second PivotTable after the source data is changed, why does that second PivotTable not show all selected source fields?
Using Windows 7, Excel 2010
UPDATE:
I just replicated this condition by doing the following:
Opened new blank workbook, while 3 other workbooks are open in the same instance
Created the following table:
Created the following PivotTable:
Added 2 new columns with arbitrary formulas:
(Text boxes, formatting, and header row insertion performed after the fact for ease of explanation)
Create new pivot table - on a new worksheet - and you can see it does not include the new fields "Payment" and "License Factor". Click refresh, and then the two new fields appear.

As pnuts says in the comments, when you create a PivotTable that uses the same data range as an existing PivotTable, Excel simply reuses the PivotCache from the first PivotTable without first refreshing it.
So if you added new columns to the source data after you created the first PivotTable and before you created the second PivotTable, then neither PivotTable will have these columns in the fields pane until you refresh one of the PivotTables.

Related

Adding or removing data from excel add ins charts

I am working on an excel add in, and need to show data in chart. I am facing a problem to set data for chart as it is not in a range. I am showing only first 10 columns in chart.
I am using WorkSheet.charts.add() function to add a new chart, however it takes data as range only. My x-axis is very first row of the sheet, but data for Y-Axis can be any row selected by user. For example if user selected row 7, then I cannot create a range from "A1:J1, A7:J7" as per my understanding range must be connected cells. If I create a range "A1:J7", it shows data of other rows and I am unable to find a way to remove/hide that data. I can do it manually using Chart options from menu, but cannot find a way to do so in API.
The technique for doing this is to copy the data that should be in the chart to a range on a hidden worksheet. Then pass that range to the Worksheet.charts.add() function. There is a sample add-in that shows how to do this: Excel Add-in JavaScript Sales Tracker.

How can I generate a pivot table using this data?

I have this table:
Is it possible to make a pivot table to present the information like this?:
Thanks!
Sure it's possible. As shown in your example, you just need to change the special character "✔️" by the number 1 using "ctrl + f". Then insert a Pivot Table with the data. And finally, create a new column named TOTAL and add the "=sum()" formula to count the items from each row. Something like that:
You are going to need to move this data from the word doc you are using into an Excel worksheet, in order to generate a pivot table.
format your data like this in Excel
To start out creating a pivot table, make sure that all rows and columns are selected and record (row) must not be obscure or elusive and must be making sense. Navigate to Insert tab, click PivotTable.
You will reach Create Pivot Table dialog box. Excel fills in data range from first to last selected columns and rows. You can also specify any external data source to be used. Finally choose worksheet to save the pivot table report.
The pivot table should appear. You can then populate this table with data fields which will pop up on the right hand side. Enable the fields you wish to compare in the pivot table report.

Dynamic charts from pivot

I have a data set that I am using as an input to a pivot table. I have transformed that data set into a table, so that every-time I add something to the data set, the pivot gets updated automatically. I have also added a line of code, so that every-time a user clicks on the sheet containing the pivot table, the table gets refreshed automatically. Now I need to have a chart (linked to the pivot table) that updates automatically every-time the pivot refreshes (like rows or columns also increase/decrease).
You could use a dynamic named range in order to get the chart data to update automatically. Without knowing what your data looks like, I'll just provide you with a generic version assuming your data is in A1:C5.
=OFFSET(A1;0;0;COUNT(A:A);3)
This will create a range that is 3 columns wide and goes until the last row with data in column A.

Link Tables and Dynamically Update in Excel

I have two Excel worksheets. Worksheet A has a table that needs to be populated by the contents of the table in worksheet B. The number of rows in worksheet B's table can change and the table in worksheet A needs to dynamically grow or shrink according to the other table's state.
Linking with the paste special tool only seems to link the first row. If another row is added in worksheet B, that change is not reflected in worksheet A.
Use table format and Pivot Tables.
Use the Pivot Table to show the information in a very friendly way, connect this pivot table to the table where your data is. Here is a graphical explanation http://www.techrepublic.com/blog/10-things/10-reasons-to-use-excels-table-object/#.

Use Excel pivot table as data source for another Pivot Table

I have a Pivot table in excel that is using a raw table as its data source. This pivot table is doing a bunch of grouping and summing of rows.
I'd like to now use the result of this new pivot table as the data source for a new pivot table which will further modify this data.
Is this possible with excel? I suppose you could call it 'nested pivot tables'
Make your first pivot table.
Select the first top left cell.
Create a range name using offset:
OFFSET(Sheet1!$A$3,0,0,COUNTA(Sheet1!$A:$A)-1,COUNTA(Sheet1!$3:$3))
Make your second pivot with your range name as source of data using F3.
If you change number of rows or columns from your first pivot, your second pivot will be update after refreshing pivot
GFGDT
In a new sheet (where you want to create a new pivot table) press the key combination (Alt+D+P). In the list of data source options choose "Microsoft Excel list of database". Click Next and select the pivot table that you want to use as a source (select starting with the actual headers of the fields). I assume that this range is rather static and if you refresh the source pivot and it changes it's size you would have to re-size the range as well. Hope this helps.
I guess your end goal is to show Distinct (unique) values inside your original Pivot table.
For example you could have data set with
OrderNumber, OrderDate, OrderItem, orderQty
First pivot table will show you OrderDate and sum of OrderQty and you probably want to see Count of unique orders in the same Pivot.
You woudln't be able to do so within standard pivot table
If you want to do it, you would need Office 2016 (or perhaps pover Pivot might work).
In office 2016 select your data > Insert > Pivot Table > choose tick "Add this data to the Data Model"
After that, you would be able to select grouping method as Distinct (Count)
As suggested you can change the pivot table content and paste as values.
But if you want to change the values dynamically the easiest way I found is
Go To Insert->create pivot table
Now in the dialog box in the input data field select the cells of your previous pivot table.
You have to convert the pivot to values first before you can do that:
Remove the subtotals
Repeat the row items
Copy / Paste values
Insert a new pivot table
As #nutsch implies, Excel won't do what you need directly, so you have to copy your data from the pivot table to somewhere else first. Rather than using copy and then paste values, however, a better way for many purposes is to create some hidden columns or a whole hidden sheet that copies values using simple formulae. The copy-paste approach isn't very useful when the original pivot table gets refreshed.
For instance, if Sheet1 contains the original pivot table, then:
Create Sheet2 and put =Sheet1!A1 into Sheet2!A1
Copy that formula around as many cells in Sheet2 as required to match the size of the original pivot table.
Assuming that the original pivot table could change size whenever it is refreshed, you could copy the formula in Sheet2 to cover the whole of the potential area the original pivot table could ever take. That will put lots of zeros in cells where the original cells are currently empty, but you could avoid that by using the formula =IF(Sheet1!A1="","",Sheet1!A1) instead.
Create your new pivot table based on a range within Sheet2, then hide Sheet2.
Personally, I got around this in a slightly different way - I had a pivot table querying an SQL server source and I was using the timeline slicer to restrict the results to a date range - I then wanted to summarise the pivot results in another table.
I selected the 'source' pivot table and created a named range called 'SourcePivotData'.
Create your summary pivot tables using the named range as a source.
In the worksheet events for the source pivot table, I put the following code:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
'Update the address of the named range
ThisWorkbook.Names("SourcePivotData").RefersTo = "='" & Target.TableRange1.Worksheet.Name & "'!" & Target.TableRange1.AddressLocal
'Refresh any pivot tables that use this as a source
Dim pt As PivotTable
Application.DisplayAlerts = False
For Each pt In Sheet2.PivotTables
pt.PivotCache.Refresh
Next pt
Application.DisplayAlerts = True
End Sub
Works nicely for me! :)
here is how I've done this before.
put a dummy column "X" off to the right of your source pivot table.
click in that cell and start your pivot table.
once the dialogue box pops up you can edit the data range to include your pivot table.
this may require you to Refresh the source table first and then refresh your secondary pivot table...or do refresh all twice
I love the offset option -- i had to create a range called that first and did a -3 instead of a -1. Then used that new range for my new pivot table. Now when the first pivot changes, the second will pickup the new rows (or less rows)...

Resources