Filter Pivot Table Generated From PowerQuery Data Model

jdorby

New Member
Joined
Jul 28, 2014
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a pivot table that was generated by using a power query data model. I have a filter on the pivot table called "EmpName" and I would like to iterate through all the EmpNames in the filter, copy the resulting pivot table data to a new workbook and save it as an entirely new workbook, and then move on to the next "EmpName".

My main issue is writing the "For each" statement to iterate through all the report filters in the pivot table.

When I used the macro recorder and interacted with the report filter in the pivot table (that was generated from the data model) this was the code generated:

VBA Code:
ActiveSheet.PivotTables("pvt_prepare").PivotFields("[master_name].[EmpName].[EmpName]")
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi,

I have a pivot table that was generated by using a power query data model. I have a filter on the pivot table called "EmpName" and I would like to iterate through all the EmpNames in the filter, copy the resulting pivot table data to a new workbook and save it as an entirely new workbook, and then move on to the next "EmpName".

My main issue is writing the "For each" statement to iterate through all the report filters in the pivot table.

When I used the macro recorder and interacted with the report filter in the pivot table (that was generated from the data model) this was the code generated:

VBA Code:
ActiveSheet.PivotTables("pvt_prepare").PivotFields("[master_name].[EmpName].[EmpName]")
Cross-posted here: Excel Help Forum
 
Upvote 0

Forum statistics

Threads
1,215,212
Messages
6,123,655
Members
449,113
Latest member
Hochanz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top