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.
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 Name | Data Type |
|---|---|
| EquipmentName | Single line of text |
| Category | Choice (Tent, Chair, Table, Lighting) |
| DailyRate | Currency |
| IsAvailable | Yes/No |
| DateAdded | Date and Time |
Sample data (two rows):
| EquipmentName | Category | DailyRate | IsAvailable | DateAdded |
|---|---|---|---|---|
| 10x10 Pole Tent | Tent | 150.00 | Yes | 2026-04-01 |
| Folding Chair White | Chair | 2.50 | Yes | 2026-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:
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:
[
{
"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"
}
]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:
-
PowerApps (V2) trigger – Add an input parameter of type
arraycalleddataInput. Paste the JSON sample you copied earlier to generate the schema automatically. -
Parse JSON – Use the same schema to parse the incoming
dataInput. -
Create CSV table – Connect to the Excel Online (Business) connector. Set Input to the
Bodyof the Parse JSON action. Choose the order of columns as desired. -
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 expressionconcat(uriComponentToString('%EF%BB%BF'), body('Create_CSV_table')) -
Create file – Store the CSV in a location accessible to the user. For example, using OneDrive for Business: folder path
/Exports, filenameEquipmentExport.csv, file content from the Compose output. -
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.
-
Respond to Power Apps – Add a Response action. Set a parameter named
downloadLinkand assign it the sharing link URL.
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:
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:
| Problem | Likely Cause | Resolution |
|---|---|---|
| Special characters (€, £, ñ) look wrong in Excel | CSV not UTF‑8 encoded | Make sure the BOM compose step is present and the expression is correct. |
| Flow errors with “Invalid JSON schema” | JSON sample doesn’t match actual data | Re‑generate the sample from your app and update the Parse JSON action. |
| File is created but “Download” doesn’t start | Sharing link not a direct download | In 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 out | JSON serialisation or flow duration limit | Restrict export to a filtered collection or a limited number of rows (e.g., FirstN(…, 2000)). |
Performance and Security Notes
- The
JSONfunction 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
JSONfunction 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
- Original article that inspired this workflow: Matthew Devaney – Power Apps Export To Excel As A CSV File
- Microsoft Learn: JSON function
- Microsoft Learn: Download function
Create a professional signature popup using the Pen Input control and save the result to a SharePoint document library with Power Automate.
Practical techniques for building collections that exceed the standard delegation threshold, including concurrent batch loading, dynamic filtering with ForAll, returning large datasets from Power Automate, and importing static Excel data.
Eliminate the login requirement for new team members: use a Power Automate flow to force-sync users and update the Dataverse team when they are added to an Entra security group.