Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
kur83
Helper I
Helper I

How to Automatically Update Excel from a Power BI (Fabric) Model with New Data and Workspaces

I am currently working on a project where I need to display data from a Power BI (Fabric) model as a table in excel. My use case involves periodically receiving new data, which results in the creation of a new workspace and semantic model, both named identically to the previous ones. I am seeking a method to automatically update my Excel spreadsheet to reflect these changes in the background.

I've explored the possibility of using VBA to update the Excel connection. However, I'm unsure about the best way to handle credential in this scenario. Specifically, I need to pass credentials securely to refresh the data connection without manual intervention.

Has anyone dealt with a similar situation or have suggestions on how to efficiently manage credentials for automated data refreshes in Excel? Any advice or best practices would be greatly appreciated.

6 REPLIES 6
v-sshirivolu
Community Support
Community Support

Hi @kur83 ,

Thanks for reaching out to Microsoft Fabric Community Forum.
If you want Excel workbooks to refresh automatically from Power BI Fabric without breaking connections, the Hub model approach works really well. The idea is to create a stable dataset (Hub model) that acts as a single source for all your Excel files. Instead of pointing Excel directly to workspace models, connect it to the Hub. Then, when a workspace dataset changes, just link the new version to the Hub using Linked Dataset or Promote to Certified - Excel keeps refreshing because the Hub’s GUID doesn’t change.

Store the workbook in SharePoint or OneDrive, which makes it easy for Office Scripts and Power Automate to refresh the data even if your PC is offline. With Office Scripts, you can refresh the dataset inside Excel, and Power Automate lets you schedule it daily or hourly. Make sure to use a service account with read access to the Fabric datasets and your cloud storage so everything runs smoothly. For large setups, you can also track refreshes in a SharePoint list or Fabric table, send email alerts for failures, and automatically retry any failed refreshes. This approach keeps everything automated, secure, and resilient to model updates.

Can you please provide more details on this on how to do this (any article or tutorial on this)? If I want to have multiple dataset active at once, will it work? 

Hi @kur83 ,

Here are resources:

Microsoft Documentation:
https://learn.microsoft.com/en-us/power-bi/collaborate-share/service-analyze-in-excel https://learn.microsoft.com/en-us/power-bi/connect-data/refresh-excel-file-onedrive
Video Tutorial: https://www.youtube.com/watch?v=46Ek6XFVAuI

If you need to work with multiple datasets at the same time, the Hub model is still effective. You can connect each workspace dataset to the Hub using Linked Dataset or Promote to Certified, so Excel remains connected only to the Hub. This setup allows Excel to access a unified and consistent model, even though several datasets are connected in the background. When you add or update a dataset, just update the Hub links - Excel refreshes will keep working since the Hub’s GUID stays the same.

Hi @kur83 ,

I hope the information provided above assists you in resolving the issue. If you have any additional questions or concerns, please do not hesitate to contact us. We are here to support you and will be happy to help with any further assistance you may need.

 

MJParikh
Advocate I
Advocate I

In my opion, Do not rotate workspaces if you want Excel to update itself. Stabilize the semantic model endpoint, then schedule refresh of the workbook.

Here is a practical setup that works in enterprises.

  1. Stop recreating workspaces
    • Keep one “Prod” workspace.
    • Replace the semantic model in place. Use Fabric Deployment Pipelines or a release script.
    • This preserves the dataset GUID. Excel points to a stable GUID, so no relink.

  2. Use a service account, not VBA-embedded creds
    • Create a dedicated AAD user with the right licenses and MFA via Conditional Access exception or authentication strength that supports unattended flows.
    • Grant Viewer + Build on the workspace, or direct permission on the semantic model.
    • Do not store secrets in VBA or in the workbook.

  3. Store the workbook in SharePoint or OneDrive
    • Excel Online supports unattended refresh via Office Scripts and Power Automate.
    • Keep the workbook connection as “From Power BI semantic model” so it uses your tenant’s Analysis Services endpoint.

  4. Schedule background refresh of Excel
    Use Power Automate, not VBA. Flow outline:
    • Trigger: Recurrence.
    • Action: Run script on workbook (Office Scripts).
    • Script does two things: workbook.refreshAll(); then workbook.save().
    • Connection identity is the service account behind the Power Automate Excel connector. No password in code.

Office Scripts snippet (paste in Automate tab in Excel Online):

function main(workbook: ExcelScript.Workbook) {
  // Refresh all data connections and PivotTables
  workbook.refreshAllDataConnections();
  // Some tenants need both calls
  workbook.refreshAll();
  // Save after refresh so downstream users get fresh cache
  // Saved automatically at end of script in Excel Online, but call setDirty to force save
  workbook.getApplication().calculate(ExcelScript.CalculationType.full);
}
 

Notes
• This refreshes the Excel view of the Power BI model. The model itself still needs its own refresh schedule in Fabric.
• Keep the Fabric semantic model refresh on a separate schedule using Power BI service or REST API. Use a service principal or the same service account.

If you must keep creating new workspaces and new models
You need an indirection layer so the Excel connection never changes.

Option A, “Hub model” in a stable workspace
• Create a thin composite model in a permanent “Hub” workspace.
• The thin model uses DirectQuery for AS to a “current” semantic model.
• When a new workspace and model show up, run an XMLA or TMSL “alter” to point the thin model to the new target.
• Excel stays bound to the thin model’s GUID, which never changes.
Operational steps:

  1. Create thin model once. Publish to Hub workspace.

  2. Grant Build to consumers and the service account.

  3. After each ingestion, a small job runs:
    • Finds the newest semantic model by name pattern via Power BI REST Admin APIs.
    • Issues an XMLA TMSL Alter to update the remote server/database for the thin model’s DirectQuery-for-AS source.

  4. Excel refresh picks up the new backend automatically.

Option B, programmatically retarget the Excel connection
• Last resort. Use a script to overwrite the connection string in the workbook to the new dataset GUID, then refresh.
• Do this from a secure process, not from user VBA.
• Pattern:

  1. Azure Function with service principal calls Power BI REST APIs to resolve the dataset GUID by name.

  2. The function returns only the GUID to a flow.

  3. The flow runs an Office Script that edits the OLAP connection to use the new GUID, then refreshes and saves.
    Caveat: Office Scripts does not expose OLAP connection editing in all tenants. If blocked, use the thin “Hub model” approach instead.

Credential handling, best practice


• Use a service account or service principal wherever an API is involved.
• Store secrets in Azure Key Vault.
• In Power Automate, use a custom connector or HTTP action with Managed Identity when possible.
• Never place client secrets in workbook cells, Names, or VBA modules.

 

Security and governance checklist


• Workspace access: Viewer for consumers, Contributor for automation, Admin for release.
• Build permission on the semantic model for Excel users.
• Endorse the model, add a friendly description, and pin it to OneLake Data Hub for discoverability.
• Turn on sensitivity labels if needed, they flow to Excel.

 

I can't keep the only one workspace as every project would require their own workspace for data confidentiality and access management. Additionally, two or more projects would run simultaneous, so only one set of data would not work out.

I have tried above office script using Automate, scripts run successfullu but data is not updating. 

Helpful resources

Announcements
September Fabric Update Carousel

Fabric Monthly Update - September 2025

Check out the September 2025 Fabric update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.