Forum

2.04 Updating a Piv...
 
Notifications
Clear all

2.04 Updating a Pivotchart with macros

7 Posts
2 Users
0 Reactions
105 Views
(@cmg)
Posts: 15
Eminent Member
Topic starter
 

I have a basic Dashboard that has one data table and four pivotcharts, NO pivot tables. Is there a way to modify the auto-updating macros in lesson 2.04 to work with pivot charts that are not linked to a pivot table? Maybe it is bad practice to not link a pivot table??? I was trying to save space by excluding them where "not needed". Thanks for any suggestions. 

Sub RefreshPT()

Dim pt As PivotChart
' Dim pt As PivotTable
Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets

For Each pt In ws.PivotChart

pt.RefreshChart
'pt.RefreshTable
Next pt

Next ws

End Sub

 
Posted : 12/05/2022 11:07 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Michael,

A Pivot Chart not connected to a PivotTable because it's coming direct from Power Query or Power Pivot? If so, then you can record a macro that Refreshes All e.g.:

Sub RefreshAll()
'
' RefreshAll Macro
'

      ActiveWorkbook.RefreshAll
End Sub

 

This will refresh all data connections/queries too. 

Mynda

 
Posted : 12/05/2022 6:47 pm
(@cmg)
Posts: 15
Eminent Member
Topic starter
 

Hi Mynda, 

I have a dedicated data workbook and I then use a query to update the data table in my dashboard workbook. I use power pivot to create the charts from the data table. I did write a macro to refresh as you suggested. 

Thank you once again!

Michael

 
Posted : 13/05/2022 9:19 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Michael,

Just to be sure, the query should get the data from the external data workbook and load it directly to Power Pivot/the data model in the dashboard workbook. It shouldn't go to a table in an Excel worksheet in the dashboard workbook and then to Power Pivot.

Mynda

 
Posted : 13/05/2022 7:52 pm
(@cmg)
Posts: 15
Eminent Member
Topic starter
 

Hmmm...If I click Refresh All in the Dashboard workbook with a table data cell selected It updates the table data, and if I select a pivot chart in the Dashboard workbook on the dashboard sheet and click refresh data again the charts update.

I'm not sure how I set it up??? Can you direct me to the lesson(s) where making sure the data query is feeding into the data model in power pivot was covered? I have all 3 (PP, PQ, DB). I'm not sure which course covers it best. 

Thank you for your patience.

Michael 

 
Posted : 14/05/2022 1:43 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Micheal,

The problem you are currently having where you have to refresh twice to get the PivotTables to update is caused by loading the data to a table in Excel and then loading it to the Data Model/PowerPivot. 

See the Power Query course lesson 5.02 for the correct procedure for loading data to the data model/Power Pivot.

Mynda

 
Posted : 14/05/2022 6:59 pm
(@cmg)
Posts: 15
Eminent Member
Topic starter
 

Hi Mynda

Yes, that helped. I removed the table in the dashboard workbook and reworked the power query in the Data workbook to feed the data model. Now my pivot charts are pulling directly from the model data in PP. 

Your time and help are much appreciated!

Michael

 
Posted : 18/05/2022 1:54 pm
Share: