cancel
Showing results for 
Search instead for 
Did you mean: 
darogael

Export to CSV Using Power Automate

Introduction:

The blog walks you through how you can export items from a gallery into a CSV using Power Automate with a OneDrive for Business connection.

 

Requirements:

  1. A Power App with a data connection to provide data for a gallery
  2. A Power Automate flow which data connection to OneDrive for Business

 

Step 1: Create and send the data from Power App.

Have an app created with a gallery that contains the data you need. You can even provide the option to filter the gallery based on the item selected from the drop down control.

 

We then collect all the items from the gallery in a temporary collection called ExportCSVCol. Then data from this collection is appended to a Set variable, to make sure the data is saved row-by-row we use the Char(10) at the end.

Finally the external variable is set to OneDrive to make the conversion to CSV using flow. Here is a screenshot of the formula:

Capture1.JPG

 

Step 2: Convert the data from Power App into a CSV file.

We now create a three step flow in Power Automate to receive the data from our app and convert it into a CSV file using OneDrive for Business. The converted CSV file is stored in OneDrive.

Important: It is important to note that this is a temporary file that must remain in OneDrive for Business and SHOULD NOT BE DELETED. You will be referencing this file in your app to download the CSV. This CSV file is auto-updated.

 

Here is a screenshot of the flow

Capture2.JPG

 

Step 3: Download the CSV file

In your Power App go back to the button you built in Step2 and add the remaining formula at the end. Notice the &Download=1 at the end? That is what forces the CSV file to download. The HTTP URL is what you get from OneDrive, the video walks you through the steps.

 

picture4.png

 

Here is a screenshot of the entire formula for the button

Capture3.JPG

Video:

This video walks you through the entire process step-by-step.

Conclusion:

Following the steps provided you can successfully export items from the gallery as a CSV file. By default the gallery will hold only 500 items. You can increase that to 2000 by changing the Data row limit in Advance Settings or you can add more filters to the gallery to only get the data you desire.

Comments

Great solution, up until more than one person clicks on Export and one of them gets an error or one gets the wrong export.  I would code in the actual path to the file using the site/library/file instead of the SharePoint generated GUID filled URL, and stamp something unique into the name per Export click so that multiple files are being created (multi-user compatible), and then also follow up with some cleanup deletion of the temporary file.

 

This aside, the whole PowerApps infrastructure, how you need to throw files in temporary locations between 3 or 4 different cloud solutions while paying subscription fees to someone to have access to a premium connector to do all of this is just so hacky and inefficient.  If I were coding this in an actual website with actual code, there would be no temporary hacky anything.  Click export, generate CSV in memory, throw the byte[] array and appropriate content-type at the browser, done.

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/