1

I have 4 pivot charts that rely on data that is refreshed from a connection.

When I click refresh all I lose all the formatting I set up (colours/borders/line and bar and 2nd axis choices)

  • I have already unchecked Properties Follow Chart Data Point for Current Workbook.
  • I have also tried Right Click on Data > Refresh per data table but I get the same issue.
  • Preserve cell formatting on update is ticked for all charts.
  • Invert if negative option ticked/unticked doesn't make a difference
  • Preserve cell formatting on update I have tried unticking, then ok, then right click options and re tick, still didnt work..
  • I have saved the chart format as a template then after refresh re applied but formatting is still lost.

Version:

Excel 2016 MSO (16.0.4738.1000) 32-bit

enter image description here

  • Is Making Regular Charts from Pivot Tables a useful solution? – harrymc Nov 5 '18 at 11:43
  • @harrymc Thank you for your input, unfortunately this would only benefit not having pivot tables and a pivot chart from data and just the chart, but this is not the issue. – Matt Nov 6 '18 at 10:10
  • I found some report that says that it helps to open the pivot table options and unticking "preserve formatting", closing the option box, then reopening it and selecting again "preserve formatting" (link). There is also the complicated Solution #2 from this article. – harrymc Nov 6 '18 at 10:22
  • @harrymc Let me try that now – Matt Nov 6 '18 at 10:33
  • The tick and untick didnt work – Matt Nov 6 '18 at 12:18
1

@Matt - same as you, none of the solutions above worked for me either. What was more frustrating was that I had two Pivot Chart/Tables in the same file, both linked to the same Power Pivot data model, one would maintain its custom formatting but the other would not. Thus I knew it was very unlikely related to my version of excel or a specific bug.

The article linked by harrymc contains the key clue to resolving this, but not using the workaround - it's the XML. I was at the point of comparing the XML for the two Pivot Charts but then thought there may be a formatting hierarchy at work here.

My solution:

  1. Delete any dependent Pivot Chart(s) (You're starting from scratch)
  2. Delete ALL slicers and remove ALL filters from the Pivot Table.
  3. Ensure that 'Preserve cell formatting on update' is ticked (this won't solve the issue directly but seems important)
  4. Add a new Pivot Chart but DO NOT filter or slice the data in any way regardless of how bad the chart may look at this stage.
  5. Apply the custom formatting.
  6. Save the file (a user in another forum suggested exiting and restarting Excel - which I did out of desperation!)
  7. Now add in the filters/slicers to create the desired chart.

I was then able to refresh/slice/filter the data and the custom chart formats were all preserved.

  • 1
    Thanks for the extra information, I ended up just using a BI tool. – Matt Jan 4 at 13:18
1

To keep the formatting when you refresh your pivot table, do with following steps:

  1. Select any cell in your pivot table, and right click.

  2. Then choose PivotTable Options from the context menu.

  3. In the PivotTable Options dialog box, click Layout & Format tab.
  4. Then check Preserve cell formatting on update item under the Format section.
  5. Finish with OK to close.

Now, whenever you format your Pivot Table and refresh it, the formatting will not be disappeared any more.

Edited 1:

You may try these :

Invert if negative option must be checked for Pivot Chart Options.

Or you may write this VBA Code in Immediate Window.

Worksheets("Sheet1").ChartObjects("Chart 1").Chart.SeriesCollection(1).InvertIfNegative = True

Note: Sheet, Chart & Series number are editable.

Edited 2

Another possibility is,,

  1. Select the Plot Area, Right Click and select command Save as Template".

Whenever you loose the Chart Format, reach to Excel, File Select the graph.

  1. Right Click and select Change Chart Type.

  2. Select the Template from the Chart type poping up Menu.

You find all those lost Formats on the Selected Chart applied previously.

N.B.

Above shown process can be implemented through VBA (Macro) on a Chart or an all Charts also.

  • Its a pivot chart, not a pivot table, nevertheless this is ticked on everything. – Matt Nov 6 '18 at 10:05
  • @Matt,, Preserve formatting on update setting somewhat resolves the issue, as that is what I see as well in my tests. – Rajesh S Nov 6 '18 at 10:54
  • @Matt,, invert if negative option must be checked in a pivot chart. Or write this VBA Code in Immediate Window. Worksheets("Sheet1").ChartObjects("Chart 1").Chart.SeriesCollection(1).InvertIfNegative = True – Rajesh S Nov 6 '18 at 11:05
  • @Matt,, check the post now I've edited the Answer so far will work !! – Rajesh S Nov 6 '18 at 11:34
  • Invert if negative option doesn't work – Matt Nov 6 '18 at 11:36
1

The article Pivot Chart Formatting Changes When Filtered treats the subject in depth.

It explains that Excel actually stores formatting data in a cache with all the other chart properties. This means that it remembers the exact formatting. When the data is refreshed, Excel invalidates this cache, so that the default formatting for the chart is applied.

It offers a solution where a new area on the worksheet is created that contains a replica of the PivotTable, containing formulas that reference the PivotTable, using either the direct cell references like (=C9) or the GETPIVOTDATA() function to point to the PivotTable. The GETPIVOTDATA function is preferable for the display of a subset of the PivotTable data in the chart.

This is done in two steps.

Step 1

The first step is to recreate the PivotTable data by creating formulas that reference the pivot. This can be done in cell adjacent to your PivotTable or on a separate worksheet. Just remember to leave enough blank rows/columns between your PivotTable and formula based table in case your PivotTable expands when filters are applied/removed.

enter image description here

Step 2

Step two is to create a regular chart using the new formula driven table as the source of the chart. When the PivotTable is filtered or sliced, the formulas will automatically be updated and display the new numbers from the PivotTable. The chart will also be updated and display the new data.

enter image description here

Conclusion

The article concludes with :

Adding slicers to your PivotCharts and PivotTables is a great way to make your presentation interactive. PivotCharts allow you to link your chart to a data source so they can be refreshed dynamically with little maintenance. However, PivotCharts display some odd behavior when filtering charts with custom formatting. Understanding this behavior and planning for it at design time will save you time and frustration.

An example presentation can be downloaded from
PivotChart Formatting Changes On Filter Slicer.xlsx.

The author also recommends the article Dynamic Chart using Pivot Table and VBA with the approach of using VBA to create dynamic charts using a more advanced approach (too long to include here).

  • Cant recreate the combo chart stacked bar and line i have with this method – Matt Nov 7 '18 at 11:31
  • Have a look at the example presentation. – harrymc Nov 7 '18 at 20:24
  • Yeh i can create a line/bar chart, but not a combo – Matt Nov 8 '18 at 10:40
0

The best solution to this recurring error is : Select the whole pivot table --> go to Analyze option on the ribbon bar --> Actions section --> click on Select --> entire pivot Now perform whatever formatting you want and save the sheet, once done use the refresh. This worked absolutely correct for me .

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.