PowerApps Export Collection Data as CSV


This came in handy when I needed the user to be able to export data in a collection for  to be used in Excel. Sample App available in the PowerApps bank.

As an example, I have a collection called Contacts with 3 records, this is the collection I will be exporting.

ClearCollect(Contacts,{Firstname:”Charles”,LastName:”Osei”,Number:”123456″ } ,{Firstname:”Charlie”,LastName:”Bradbury”,Number:”8765432″ },{Firstname:”Joh”,LastName:”Smith”,Number:”123456″ } )

On a button. Create a collection called ExportCSV with the same columns as  the contacts collection, but pre populate the first row with the column names , this will be the CSV`s column headers.

ClearCollect(ExportCSV,{Firstname:”First Name”,LastName:”Last Name”,Number:”Number”})


Next step is to copy all the Contacts into the ExportCSV collection

ForAll(Contacts,Collect(ExportCSV,{Firstname:Firstname ,LastName:LastName, Number:Number}))


Create the CSV string into a variable by concatenating all the columns with a comma. You can add in your extra columns by  adding &”,”&

but the concat  must end with “& Char(10)”  as this separates the next line.

Set(MyString,Concat(ExportCSV,Firstname&”,”&LastName&”,”&Number& Char(10)))


Output the MyString variable to a multi-line text box by setting its default value to MyString. Which should look like the below.

First Name,Last Name,Number

You can now copy and paste that text into notepad, save it as something.csv. The file can now be opened in excel,you can use the column headers as filters or to create a table.



Choose your Reaction!
Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.