Forum Discussion

Raki39's avatar
Raki39
Helper I
5 months ago
Solved

Trigger Power Automate from Power BI report button to export report data to Excel (with formatting)

Hi everyone,
I am trying to implement a feature in a Power BI report (.pbix) where users can click a button and automatically export the report data toexcel format.

Scenario:
* The Power BI report is published in a Power BI Service workspace.
* Users who have access to the report should see a button inside the report.
* When the user clicks the button, it should trigger a Power Automate flow.
 
Expected behavior:
* The flow should export the report data to an Excel file.
* The data structure and formatting (column names, numeric formats, dates, etc.) should be preserved.
* The exported file should be saved in the user’s personal location, such as:
  Their OneDrive folder, or A SharePoint folder.
 
Questions:
1. Is it possible to trigger a Power Automate flow directly from a button inside a Power BI report?
2. What is the recommended approach to extract the data from the report or dataset and generate an Excel file with the formatting preserved?
3. Can the flow dynamically save the file to the logged-in user’s OneDrive or SharePoint location?
4. Are there any recommended APIs or Power Automate actions to achieve this scenario?
 
Any guidance, documentation, or example flow designs would be greatly appreciated.
 
Thanks in advance!
 
 
 
 
  • Hi Raki39,

     

    This is the expected behavior. When a Power Automate flow is triggered from Power BI, it uses the flow owner's connections rather than the user's identity who triggered it. As a result, actions like Create file in OneDrive will always write to the OneDrive linked to the flow owner, so files are created in your OneDrive even if other users run the report.

    Currently, Power Automate does not allow the OneDrive or SharePoint connection to switch dynamically based on the triggering user. This means the flow cannot create files in each user's personal OneDrive when using a shared flow.

    To address this, a common solution is to store the generated file in a central SharePoint document library and provide access to the user who triggered the export. You can identify the user (for example, using Power BI visual context or user information passed to the flow) and then share the file link or send it automatically. This lets each user access their exported data without relying on the flow owner's OneDrive.

    This approach keeps the storage location consistent while enabling users to retrieve their exported files from the report.

     

    Thank you and Contiue using Microsoft Fabric Community Forum.

8 Replies

    • Raki39's avatar
      Raki39
      Helper I

      Hi Juan-Power-bi 
      Thank you for the response and for sharing the reference video on creating the flow. However, the current approach is quite slow—inserting 200 records took nearly 6 minutes.I have acheived using Json script using Run script.

      Currently, all the flows are creating the files in my OneDrive, which is not the actual requirement. As I mentioned earlier, the file should download to the OneDrive or SharePoint folder of the user who runs the report.
       
      However, both the video you shared and the flow I implemented (faster using Json script) are downloading the files only into my OneDrive folder, eventhough, it was triggered by a different user. since the flow is running under my connection.
       
      What I am looking for is a solution where the flow can create the file dynamically for each user, so that the output file is saved in the respective user’s OneDrive or their designated SharePoint folder, based on who triggers or runs the report.
       
      Could you please let me know if this is possible and what approach can be used to achieve this?



  • v-sgandrathi's avatar
    v-sgandrathi
    Community Support

    Hi Raki39,

     

    Thank you Juan-Power-bi for sharing the tutorial here.

    Yes, you can trigger a Power Automate flow from a Power BI report, but this can't be done with a standard button visual. Instead, you should use the Power Automate visual in Power BI, which lets users run a flow directly from the report in Power BI Service. When setting up the visual, you can pass specific dataset fields to the flow. Once the report is published, users choose the relevant data context and click Run Flow to start the process.

    To export data to Excel, pass the necessary fields from the Power BI visual to Power Automate. Within the flow, use actions like Create CSV table or Add a row into a table (Excel Online Business) to organize the data, and then Create file to generate the Excel file. This file can be saved to a SharePoint or OneDrive location linked to the flow. Note that while data structure is preserved, visual formatting from Power BI isn't automatically applied in Excel, so you might need an Excel template for formatting.

    Saving the file directly to each user’s personal OneDrive is challenging, as flows typically run under the flow owner’s connection and save files to a set location. A common solution is to store the file in a shared SharePoint folder and send users a link by email. If you need to export a full report with layout and formatting, consider using Paginated Reports, which support native exports to Excel and other formats.

     

    Thank you and Continue using Microsoft Fabric Community Forum.

  • v-sgandrathi's avatar
    v-sgandrathi
    Community Support

    Hi Raki39,

     

    This is the expected behavior. When a Power Automate flow is triggered from Power BI, it uses the flow owner's connections rather than the user's identity who triggered it. As a result, actions like Create file in OneDrive will always write to the OneDrive linked to the flow owner, so files are created in your OneDrive even if other users run the report.

    Currently, Power Automate does not allow the OneDrive or SharePoint connection to switch dynamically based on the triggering user. This means the flow cannot create files in each user's personal OneDrive when using a shared flow.

    To address this, a common solution is to store the generated file in a central SharePoint document library and provide access to the user who triggered the export. You can identify the user (for example, using Power BI visual context or user information passed to the flow) and then share the file link or send it automatically. This lets each user access their exported data without relying on the flow owner's OneDrive.

    This approach keeps the storage location consistent while enabling users to retrieve their exported files from the report.

     

    Thank you and Contiue using Microsoft Fabric Community Forum.

    • Raki39's avatar
      Raki39
      Helper I

      Hi  v-sgandrathi ,
      Thank you for your response.

       
      However, this approach may not be very practical from an end-user perspective. The expected functionality where files are generated in the respective user’s OneDrive does not seem achievable using Power Automate due to the current limitations around connection context.
       
      Given that the report is embedded within a web portal, I am considering alternative approaches using Angular and .NET along with the Power BI REST APIs. This would allow better control over user context and enable a more seamless and scalable solution aligned with the requirement.
       
      Appreciate your insights, and I will explore these options further.
      • v-sgandrathi's avatar
        v-sgandrathi
        Community Support

        Hi Raki39,

         

        Thank you for your follow-up and for clearly outlining your requirement.

        You are correct in your understanding that the current behavior is expected. When a Power Automate flow is triggered from Power BI, it executes using the flow owner’s connection, which means actions like creating files in OneDrive or SharePoint will always target the flow owner’s storage. At this time, Power Automate does not support dynamically switching the connection context to the user who triggered the report, so creating files directly in each user’s personal OneDrive is not feasible using this approach.

        Considering your scenario, where the report is embedded within a web portal and requires user-specific file generation and storage, your plan to use Angular and .NET along with Power BI REST APIs is appropriate. This approach allows you to manage user context at the application level and ensures that the generated file can be delivered or stored based on the logged-in user. You can retrieve the required data using Power BI REST APIs, generate the Excel file programmatically, and then either allow the user to download it directly or store it in their respective location using Microsoft Graph.

        This design provides greater flexibility, better performance, and aligns well with scenarios that require per-user ownership and a seamless user experience

         

        Thank you.

  • v-sgandrathi's avatar
    v-sgandrathi
    Community Support

    Hi Raki39,

     

    As we did not get a response, may I know if the above reply could clarify your issue, or could you please help confirm if we may help you with anything else?

     

    Your understanding and patience will be appreciated.

  • v-sgandrathi's avatar
    v-sgandrathi
    Community Support

    Hi Raki39,

     

    we haven't heard back from you regarding our last response and wanted to check if your issue has been resolved.

    Should you have any further questions, feel free to reach out.
    Thank you for being a part of the Microsoft Fabric Community Forum!