Excel Pivot Table Not Working when Using Formula - excel

When creating values in a cell by using a formula: =IF(A2 = "RD", "RD", ""). Which says show value RD if RD and blank if not. I have three columns with different values, all set up the same way. When I try to pivot chart it, the data comes in but the count is not correct. All bars in the bar chart are exactly the same count even though the columns are filtered based on count of values (e.g., IF value is RD, count is based on RD and blanks not included). There are 37 RD values in column1, column 2 has 54 "RJ" values but bars in the chart reflect the same number which is the number of rows/cells in the table for each column. If I create the exact same chart using no formulas and use the pivot chart function, it works fine.

The issue here seems to be that pivot tables do not automatically update in some specific circumstances. That's more to do with how Excel actually flags cells for calculation updates.
SHORT ANSWER. You need to get the pivot table to refresh. Shortcut for that is click the sheet with the pivot table that isn't updating, then go to "Data" and "Refresh All". Or faster, hit keys Alt, a, r, a. (sequentially, not simultaneously)
LONG ANSWER. Do some research on dependency trees in Excel. Understanding dependency trees will explain how Excel marks cells for updates and it will allow you to make much more efficient workbooks.

Related

Excel Creating New Sheet with Summed Data from related sheet

Lets say I have the following on a sheet.
By some means, I want to either replace this, or preferably, create a new sheet, with the following data. Notice, that PO# is out of the picture, and a summation is done on rest of the fields. Is there a way to easily do this?
The end result has to be data in excel grid like below (preferably on a new sheet). This can possibly be some macro or some other technique I can use to easily create this....
You can easily do this with SUMIFS() or a Pivot Table.
For SUMIFS() the below equation will give you the sum for W.PS123 Product A. Modify as needed for your other criteria by swapping AR and product number (both housed in quotes in below formula, you can also set these equal to a cell range that contains desired criteria).
If you have a set number of "ARs" and Product Numbers, you will only need to build this table once and the equations will automatically update as your raw data changes.
=SUMIFS(C:C,A:A,"W.PS123",E:E,"A")
Alternatively, you can build a pivot table and just refresh this every time your data updates (or create a worksheet_change macro to refresh the table automatically when your data changes).
To build your pivot:
Highlight your table array (In your example, Col A-D)
Insert > Pivot Table
Drag AR to Rows
Drag PRODUCT to Rows (Below AR)
Drag QTY to "Values" and change the field to "Sum" rather the default count
Format to taste

Filter column for substring and return max of adjacent cells -- Excel 2013 (no macros)

I would like to obtain the max call time that was on each day, the average of all the calls that day, and any calls that exceeded 20 seconds.
Due to the security policies at work I am limited to the formulas provided by excel, I can't use macros or VB (otherwise I would just write something suitable). I don't have much experience with excel, so I apologize if this is a simple one. I have tried to find ways to search and return a subarray that I could easily manipulate, but it seems the only way to do that is with macros. Currently I think I can use VLOOKUP, but I don't really understand enough about it know if I can use this with another function.
Essentially, if there is a formula or a combination of formulas that I can use that will allow me to collect all data from column B that shares the same values in column A, I could nest that in the formulas I need to calculate the data.
Any help is appreciated!
This can be done with a pivot table in just a few clicks.
First, turn the source data into an Excel Table object, by selecting one cell in the table and then using Insert > Table or Ctrl-T. Add a helper column for the calls over 20 seconds. Let the column be "long calls" and the formula
=IF([#Duration]>TIME(0,0,20),1,0)
Then, with a cell of the Excel Table selected, click Insert > Pivot Table. (The pivot table is now linked to the Excel Table object and when more data is added you can refresh the pivot table without having to change the definition of the source data.)
Drag the Day field into the rows area and the Duration field into the Values area. Right-click any of the value results in the pivot table, and in the Value Field Settings dialog select Max. Then click on Number Format button and set the custom number format of hh:mm:ss. Confirm all dialogs.
If you want to format the date, right click any of the visible dates in the Pivot table, select Field Settings, click Number Format and then set the custom format ddd.
Drag the duration field into the values area again and set its calculation method to Average.
Drag the "long calls" field into the values area.
Hide the Grand Totals via the Pivot Table tools Design ribbon command.
Now you can add more data to the table in columns A to B, right click the pivot table and select refresh.

Make rows and columns dynamic so when adding a new row or column the chart automatically updates?

In MS Excel if we want to make a chart then we have to select the data range.
Is there is any way that when new entries (row or column) are added then the chart updates automatically?
I've found this to be challenging for stacked bar charts in Excel 2010. Let's take the case of a simple table with some numbers:
2016 2017
Sam 3 4
Fred 5 6
Alice 3 4
Select the table, right-click on its tab, and select insert chart. Choose stacked bar. Then, choose switch Row/Column. Now, if you go to Design | Select Data, you see a nice formula for the Chart Data Range. If you insert a row, however, and add someone else, you get a discontinuous range and they are not included in the chart. If, however, you first select your data, choose Insert | Table, and tell it it has headers, then you can insert a row, and have it included in the chart automatically as e.g. sales from an extra salesperson.
This happens only if two things occur:
It must be a table, and
It must be a continuous table range for your source data. No skipping columns. Perhaps it might work for a subset of a table.
If either is not true, it breaks it. I would criticize the way it doesn't account for inserted rows, or the way it complains about chart data ranges being too complex and doesn't even show you the text of the chart data to let you edit it, if the columns are out of order (ok, I'm complaining), but while e.g. Libre Office calc lets you edit formulas even when they are complex, it never keeps track of inserted rows to add more data series.
If you use dynamic formulas for the chart, or named regions, it just converts them into cell range references, and fails to account for inserted rows.
Create dynamic named ranges for the labels and each series, and edit the chart data to use these names.
An example for the named range is where the labels might be in column A, and some values in column B
=$B$2:INDEX($B:$B,COUNTA($A:$A))
which is defining a range starting at B2 and ending at the row in column B that corresponds to the last data row in the labels column A.
Add a named range for each series.
When pointing the chart to these names, be sure to preface it with the sheet name, even if you are on that sheet, something like
=Sheet1!2010Amounts

Excel Pivot Chart: remove zero values

I have Pivot table with one Axis field (containing 13 elements 0-12) and two Values series. One of the series (A) has 13 values. The other series (B) has only 3 elements.
When I make a pivot table, I'm able to hide the zero values using this explanation :
Excel 2010: Hide 0 values in Pivot
However when I make a pivot chart (line chart) the series B keep showing zero (or a line dropping to the x-axis). I want the line of the series B to stop when there are no values (the line should be floating on the chart).
Anyone has an idea how to achieve this ?
I faced a similar issue where the Series drops down to Zero.
I have a Pivot Chart linked to a Pivot Table with multiple Series for 7 different Key Figures & other Fields. I pick up my source data from BEx/BI using Formula to bring in some extra Columns & apply some miscellaneous formatting. This data is then forms the basis for my Pivot Table & Pivot Chart.
I found that you cannot filter the Pivot Table as the Fields do not contain items. You cannot use NA() or even "" (double-quotes) using Formula - this is because when using different kinds of aggregation within the Pivot Table the NA() cannot be SUMMED and hence the Series is not displayed. It also appears that setting a Cell to blank using "" (double-quotes) in a Formula has no effect either. I even tried #DIV/0! errors & then hiding the errors - no luck.
As a workaround, the "only" way I have found so far that works is to manually Filter my final data input for the Pivot Table by zero and then simply delete the values. Refreshing the Pivot Table then allows the Pivot Chart to hide the blanks and the data points will not be displayed. This means that any Series with intermittent values are displayed correctly.
Found a trick: in the data field use =if(x=0,na(),x/y). The graph will be fine but the table will look ugly (with #NAs). You can use conditional formatting on the table to set the font color as white when there is an error.
Voila!!!

Excel table not expanding when new data is added

I have an Excel spreadsheet which contains four data tables on the same tab. The final 3 columns in each contain formulae.
I then have a vba code which performs an sql look up within an SQL Server table and returns a set number of columns to update each of the four tables.
For three of these tables, the data is pasted in and the table automatically expands and the formulae is copied to the end of the table.
However, for the first table, the data is pasted in but the table does not expand and hence, the formulae does not get added to the rows outside of the table.
I have searched high and low for a fix but no joy. I have searched the data extraction VBA code with no luck (the code is an exact match) and no joy in the table properties. I have also checked the Options menu for Auto Format As You Type settings but all seems fine.
Does anyone have any ideas for me?
Thanks,
David.
Hi All again,
Would love to know if anyone has an answer for this but, in the mean time I have fudged the code to automatically adjust the size of the table based on the row number for the last cell of data.
Thanks,
David.
I ran into the same issue and it was driving me nuts. Found out that in a few columns I had dragged formulas down pretty far (they were IF statements to return nothing if the first column was empty) so I didn't see them.
So remove any formulas that are 'under' the last row of the table. Should clear up the issue.
The most common cause is due to differing number of, or mis-aligned columns (vertically stacked tables) or differing number of, or mis-aligned rows (horizontally stacked tables).
For simplicity, let us use vertically stacked tables to illustrate what is happening. Consider an upper table with 2 columns and a lower table with 3. If we try to insert a row to the upper table, XL attempts to push all cells beneath the table down, but ONLY the cells directly beneath the table. So in this case cells below the 2 columns will be pushed down. XL quickly realizes that if it pushes just 2 columns down, the third column in the lower table won't be pushed down resulting in skewing the lower table. XL makes no attempt to figure out how to move the lower tables. It just refuses to even try.
The same holds true for adding columns to tables on the left for which there are tables directly to the right. If adding columns to a table would result in skewing rows of a table to the right, XL refuses to help.
To keep this from being a problem we can do a few things:
Keep the largest tables on top and to the left and align all table first columns and first rows.
If only rows are added to tables, don't stack them vertically
And if only columns are added to tables, don't stack them horizontally.
Herewith is an example of enforcing expansion of a table after data was copied over to the bottom of the table. This is done by resizing the table. Originally the table wasn't auto-resized as it has additional calculation columns.
The first line of the code finds the last row of data and the second line states the range to which the table needs to be resized. The third line resizes the table to the new range.
Replace sXXX and tXXX with your sheet name and table name.
Sub ResizeTableXXX()
myLastrowOfData = sXXX.Range("A1000000").End(xlUp).Row
myNewRangeSize = "$A$5:$P$" & myLastrowOfData
sXXX.ListObjects("tXXX").Resize Range(myNewRangeSize)
End Sub
HIH

Resources