Export To CSV In PowerApps Using Power Automate

Introduction

 
In this article, we will learn today how to export the data from PowerApps to CSV format. Many times, there is a requirement from customers for exporting the result in different formats like .csv, .xlsx, etc. You’ll understand practically how we can achieve it in this article.
 
We will use PowerApps, Power Automate, and SharePoint to achieve this export to .csv functionality.
 

Create a SharePoint List

 
First, we need to create one SharePoint list that we are going to use in PowerApps to view the records in a gallery control. Below is my SharePoint list that I’ve created for this demo.
Export To CSV In PowerApps Using Power Automate

Create PowerApps

 
In the second step, we are going to create PowerApps. You need to first login to PowerApps using your tenant account and create one blank canvas app using a tablet layout and provide your app name.
 
Create SharePoint data source, click on the data source icon, and select SharePoint connector, and select SharePoint site URL and list name. For this article, I’m using the Customer list which we’ve just created in the above step.
 
Export To CSV In PowerApps Using Power Automate
In the next step, insert the vertical gallery control on the screen and select the SharePoint data source and set the Items property to Customer which is our data source, it will automatically display customer name and address in title and subtitle in the gallery control.
 
Export To CSV In PowerApps Using Power Automate
 
Now, we are going to add one button on-screen called "Load data to Collection". Using this button, we are going to create the collection for Customer information and add one column "IsChosen" as false in the Customer table using AddColumns function. Below is the screenshot for the OnSelect property of button control.
 
Export To CSV In PowerApps Using Power Automate
 
Add the checkbox control into the gallery and remove the Text property to blank as we only display the checkbox control. We need to set the Checkbox OnCheck and OnUncheck property using the Patch function to set the IsChosen flag into Collection. Below is the formula we used for Checkbox control.
 
Export To CSV In PowerApps Using Power Automate

Create Power Automate

 
Here, we need to create Power automate to create.CSV file based on the selected data from gallery control in PowerApps. Create instant flow and select PowerApps from choosing how to trigger this flow section.
 
Click on the Next Step and add Compose action and select the input parameter from dynamic contents.
 
Export To CSV In PowerApps Using Power Automate
 
Click on the Next Step and add Parse JSON action. Select output in Content and provide your JSON in Schema. (We will get the sample JSON in one variable in PowerApps).
 
Export To CSV In PowerApps Using Power Automate
 
Now, we need to add an action called Create CSV table and select the body parameters from dynamic contents, which gets all its content from PowerApps.
 
Export To CSV In PowerApps Using Power Automate
 
In the last section of Power Automate, we need to create a file and store it into the SharePoint document library. Add Create file action and select SharePoint site, Folder Path (which is document library), File Name, and select output from the Dynamic contents in File Contents.
 
Export To CSV In PowerApps Using Power Automate
 
In PowerApps, we need to use this flow and run it. For this, first, insert Button control on-screen and rename it with "Export to CSV". Click on the Action menu from the top bar and click on Power Automate and add your flow which we just created above. On the button OnSelect property, drop some columns from the collection which are not useful and convert this collection into JSON format and pass it to the flow.
 
Below is the button OnSelect property, which looks like:
 
Export To CSV In PowerApps Using Power Automate
 
Now, let's run the PowerApps and select records from gallery controls and click on the "Export to CSV" button, it will create one ExportToCSV.csv file and store it into the SharePoint document library.
Export To CSV In PowerApps Using Power Automate
I hope you enjoy this article and learn about the export functionality in PowerApps using SharePoint and Power Automate. Happy Learning!