Skip to main content

Notifications

Community site session details

Community site session details

Session Id :

How to Apply Pivot Table in Excel Using Power Automate Desktop

VishnuReddy1997 Profile Picture VishnuReddy1997 2,443 Super User 2025 Season 1

🚀 How to Apply Pivot Table in Excel Using Power Automate Desktop


✨ Introduction

Working with large volumes of data in Excel can be overwhelming without proper summarization. One of the most powerful tools for summarizing data is the Pivot Table. But what if you want to automate the entire process — from opening your input data to generating a pivot table — without manual clicks?

👉 Many suggest using VBScript to automate Pivot Table generation. However, in my experience, VBScript didn’t consistently produce the desired results—especially when handling dynamic input data or formatting. To overcome those limitations, I opted for a more robust and flexible approach using Power Query and a pre-defined Pivot Table template. This method works reliably and integrates well with Power Automate Desktop (PAD).

This blog will walk you through how to create a Pivot Table template using Power Query and automate it using PAD. Whether you're an RPA enthusiast or a business user looking to streamline reporting, this step-by-step guide will help you automate Excel-based data summarization like a pro.





📌 Step-by-Step: Creating a Pivot Table Template using Power Query in Excel

Step 1:

Open a new Excel file. Copy your input data with headers into the sheet and format it as a Table (Ctrl + T).

Step 2:

Rename the first sheet to "InputData". Add a new sheet and name it "Pivot".

Step 3:

On the InputData sheet, go to the Design tab and click "Summarize with Pivot Table". as shown in below image.



Step 4:

In the dialog, select to insert the Pivot Table into the existing worksheet, and set the location as shown in below images.

 In Location Filed you can directly enter this "Pivot!$A$1" and then click on OK.



Step 5:

You’ll now see a blank Pivot Table ready to be configured.

Step 6:

Drag and drop the necessary fields (Rows, Columns, Values) into the Pivot Table layout as shown in below image.



Step 7:

Once you're happy with the Pivot setup, save the file as your template. You will use this file in Power Automate Desktop.

Below is example Pivot table as shown in below image.





🤖 Using the Pivot Template in Power Automate Desktop


🔧 Flow Overview

You’ll need two Excel files:


  • Input Excel (data to summarize)

  • Pivot Template (with pre-defined Pivot logic

📷 Flow Image





💡 Flow Code Snippet

#region Launch and Read Input Excel
Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: 'C:\\Users\\OneDrive\\Desktop\\Input Excel.xlsx' Visible: True ReadOnly: False Instance => Input_ExcelInstance

Excel.ReadFromExcel.ReadAllCells Instance: Input_ExcelInstance ReadAsText: False FirstLineIsHeader: True RangeValue => Input_ExcelData

Variables.DeleteEmptyRowsFromDataTable DataTable: Input_ExcelData
#endregion

#region Launch Pivot Template and Paste Data
Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: 'C:\\Users\\OneDrive\\Desktop\\Pivot Template.xlsx' Visible: True ReadOnly: False Instance => Template_ExcelInstance

Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: Template_ExcelInstance Name: 'InputData'

Excel.WriteToExcel.WriteCell Instance: Template_ExcelInstance Value: Input_ExcelData Column: 'A' Row: 2
#endregion

#region Generate Pivot Table
Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: Template_ExcelInstance Name: 'Pivot'

UIAutomation.FocusWindow.FocusByInstanceOrHandle WindowInstance: Template_ExcelInstance

MouseAndKeyboard.SendKeys.FocusAndSendKeys TextToSend: '{Control}({Alt}({F5}))' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
#endregion



✅ Output

After executing the flow, your Pivot Table will be automatically updated with fresh data, ready for reporting — no manual refresh needed!




🔚 Conclusion

Automating Pivot Table generation in Excel using Power Automate Desktop not only saves time but also improves consistency in data processing. With this setup, your reporting can become hands-free, accurate, and repeatable.

Whether you're working in finance, operations, or analytics, this technique helps bridge Excel's powerful features with RPA capabilities.




If you have any questions or enhancements, feel free to comment below or connect with me in the Power Automate Community!


Comments