Tutorials/Power Apps/Generate CSV Downloads from Power Apps with a Power Automate Workflow
Power Appsintermediate

Generate CSV Downloads from Power Apps with a Power Automate Workflow

Build a button that exports table data to a CSV file and delivers it to the user's browser for instant download.

NA
Narmer Abader
@narmer · Published June 3, 2026

Many Power Apps users want to extract data into a format they can open in Excel. CSV files are the simplest cross‑platform option, and you can generate them on the fly using a Power Automate flow. This article shows a battle‑tested pattern that you can drop into any canvas app with minimal changes.

You’ll build an export button that converts table data to JSON, passes it to a flow, converts it to a CSV with proper UTF‑8 encoding, stores it in OneDrive (or SharePoint), and returns a download link. The user clicks the button and the CSV file lands in their browser.

Scenario: Rental Equipment Inventory

Imagine you’re managing equipment for a party‑rental company. Inventory data lives in a SharePoint list named Rental Equipment with these columns:

Column NameData Type
EquipmentNameSingle line of text
CategoryChoice (Tent, Chair, Table, Lighting)
DailyRateCurrency
IsAvailableYes/No
DateAddedDate and Time

Sample data (two rows):

EquipmentNameCategoryDailyRateIsAvailableDateAdded
10x10 Pole TentTent150.00Yes2026-04-01
Folding Chair WhiteChair2.50Yes2026-03-15

Your team wants a “Download CSV” button inside the app so they can grab an offline snapshot for warehouse checks.

Step 1: Build the App Interface

Create a canvas app from blank and add the Rental Equipment SharePoint list as a data source. Insert a Data Table control and set its Items property to 'Rental Equipment'. This gives your users a live view of the inventory.

Then add a button labelled Export CSV — you’ll wire it to the flow later.

Step 2: Generate a JSON Sample for the Flow

The flow needs to understand the shape of the data it will receive. Prepare a temporary screen with a button and a label.

Set the button’s OnSelect to:

powerfxGenerate sample JSON
Set(
  varSampleJSON,
  JSON(
      ShowColumns(
          FirstN('Rental Equipment', 3),
          "EquipmentName",
          "Category",
          "DailyRate",
          "IsAvailable",
          "DateAdded"
      ),
      JSONFormat.Compact
  )
)

Set the label’s Text to varSampleJSON. Run the app, press the button, and copy the resulting JSON array. You’ll use this sample in the next step.

The output should look like:

jsonJSON sample
[
{
  "EquipmentName": "10x10 Pole Tent",
  "Category": "Tent",
  "DailyRate": 150.00,
  "IsAvailable": true,
  "DateAdded": "2026-04-01T00:00:00Z"
},
{
  "EquipmentName": "Folding Chair White",
  "Category": "Chair",
  "DailyRate": 2.50,
  "IsAvailable": true,
  "DateAdded": "2026-03-15T00:00:00Z"
}
]
Column names in ShowColumns

Use the exact column names from your data source. If a name contains spaces, wrap it in single quotes. To be safe, check the Schema pane in Power Apps Studio to see the internal (logical) names.

Step 3: Create the Power Automate Export Flow

Go to Action > Power Automate in Power Apps Studio and click Create a new flow. Choose the Power Apps button template.

Name your flow, e.g. EquipmentExportTool. Replace the default trigger with PowerApps (V2) – this lets you define custom inputs.

Build the flow with these steps:

  1. PowerApps (V2) trigger – Add an input parameter of type array called dataInput. Paste the JSON sample you copied earlier to generate the schema automatically.

  2. Parse JSON – Use the same schema to parse the incoming dataInput.

  3. Create CSV table – Connect to the Excel Online (Business) connector. Set Input to the Body of the Parse JSON action. Choose the order of columns as desired.

  4. Compose – Prep the CSV content with a UTF‑8 Byte Order Mark (BOM) so special characters like currency symbols display correctly. Use this expression:

    textUTF‑8 BOM expression
    concat(uriComponentToString('%EF%BB%BF'), body('Create_CSV_table'))
  5. Create file – Store the CSV in a location accessible to the user. For example, using OneDrive for Business: folder path /Exports, filename EquipmentExport.csv, file content from the Compose output.

  6. Create sharing link – Generate a direct download link. Choose OneDrive for Business again, enter the file identifier from the previous action, and set sharing type to View.

  7. Respond to Power Apps – Add a Response action. Set a parameter named downloadLink and assign it the sharing link URL.

Sharing permissions

If your users need to download without signing in, adjust the sharing link type accordingly. For internal apps, a company‑wide view link is usually sufficient.

Step 4: Wire the Flow to Your App

Back in Power Apps Studio, select the Export CSV button. Open the Power Automate pane, choose your new flow (EquipmentExportTool), and it will create a Run function.

Set the button’s OnSelect to:

powerfxExport button OnSelect
Set(
  varExportData,
  JSON(
      ShowColumns(
          'Rental Equipment',
          "EquipmentName",
          "Category",
          "DailyRate",
          "IsAvailable",
          "DateAdded"
      ),
      JSONFormat.Compact
  )
);
Set(
  varFlowResult,
  EquipmentExportTool.Run(varExportData)
);
Download(varFlowResult.downloadLink)

The Download function takes the URL returned by the flow and triggers a file save dialog in the browser (or mobile device).

Step 5: Test and Troubleshoot

Press Play in Power Apps Studio and click the export button. A new browser tab may open briefly while the flow runs, then your CSV file should appear as a download.

Common issues and how to fix them:

ProblemLikely CauseResolution
Special characters (€, £, ñ) look wrong in ExcelCSV not UTF‑8 encodedMake sure the BOM compose step is present and the expression is correct.
Flow errors with “Invalid JSON schema”JSON sample doesn’t match actual dataRe‑generate the sample from your app and update the Parse JSON action.
File is created but “Download” doesn’t startSharing link not a direct downloadIn the Create sharing link action, choose Link type “direct download” if available; otherwise the user may need to click through a preview page.
Large dataset times outJSON serialisation or flow duration limitRestrict export to a filtered collection or a limited number of rows (e.g., FirstN(…, 2000)).

Performance and Security Notes

  • The JSON function runs client‑side. For very large data sources, consider collecting the needed rows into a local collection first, then export that. The function can comfortably handle 1000–2000 records but test with your own data.
  • No delegation issues – the JSON function operates on the data already retrieved.
  • The download link created by the flow may be governed by your organisation’s sharing policies. Make sure the link does not inadvertently expose data to external parties.
  • If you use SharePoint instead of OneDrive, adjust the connector actions accordingly (create file in a document library, generate sharing link, etc.).

Final Recommendation

This pattern is reusable for any data source – SharePoint, Dataverse, SQL, or even a collection. Keep a copy of the flow template so you can duplicate it for new apps. Always test the download with a sample that includes special characters and a realistic number of rows.

With a few minutes of setup, your users will never have to manually copy data out of a canvas app again.

References