cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
djg
Frequent Visitor

Collection data to csv

I have a collection in Powerapps with a large number of record fields that are populated from combo boxes etc. I need to create a csv file with this collection. I have tried using JSON via Power Automate but JSON only grabs the string fields and ignores the record fields. If JSON can't handle record fields, is there an easy way to convert the data in the collection to all string?

 

What is the best way to get this collection into a csv file?

 

djg_0-1613067189612.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@djg 

So this is vastly different than the first picture you showed.  In the first, all of your data was represented as a table in your column.

I have a feeling that you are setting the entire control into your collection.  This is not what you want to do, and JSON will not serialize a control.  Instead you want to collect the actual data in those controls.

It is the difference between:  Collect(collection, {aColumn: Combobox1})  and Collect(collection, {aColumn: Combobox1.SelectedItems})

The first stores the Combobox1 object into the collection.  The second stores the values selected into the collection.

If you have a table in a table, JSON will serialize it without an issue.

 

BUT, that still leads me to the following concern over your approach - how would you be representing table data in your csv?

 

Ex. If you have two records of :  {Column1 : 1, Column2: "A"}  and {Column1 : 2, Column2: "B"}

That would be represented in csv as:

1, A

2, B

 

But if you have two records with tables in them:   {Column1 : 1, Column2: ["A", "B", "C"}  and {Column1 : 2, Column2: ["D"]}

How would you represent that in csv?  The columns would not match.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

4 REPLIES 4
RandyHayes
Super User
Super User

@djg 

JSON is not going to give you CSV, it's going to give you JSON.

The JSON function in PowerApps will serialize the nested tables that are in your table records. Have you looked at it in PowerApps?

However, as mentioned, this will only give you JSON, not CSV.

 

If you want to get CSV, you will need to utilize the Concat function to iterate on table records and to provide a text result.

Your challenge will be that it appears that ALL of your columns contain nested tables.  So, you will not only need to "CSV" the record, but also the tables inside of each record.

How would you even represent a nested table in a CSV line?

 

I hope this is helpful for you.

 

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
djg
Frequent Visitor

Thanks for replying @RandyHayes 

My plan is to use Power Automate to Parse the JSON and then create a csv from the parsed data.

 

The image below shows the collection data that I used to set the JSON and a Label underneath with what is contained in the JSON.  The first three columns in the Datatable are from text inputs and the other columns are from combo boxes.

 

djg_0-1613088049901.png

 

The issue that I am having is that the JSON is only retrieving the text input fields from the collection and not retrieving the combo box fields. Looking for a way to make JSON take all fields from my collection.

 

RandyHayes
Super User
Super User

@djg 

So this is vastly different than the first picture you showed.  In the first, all of your data was represented as a table in your column.

I have a feeling that you are setting the entire control into your collection.  This is not what you want to do, and JSON will not serialize a control.  Instead you want to collect the actual data in those controls.

It is the difference between:  Collect(collection, {aColumn: Combobox1})  and Collect(collection, {aColumn: Combobox1.SelectedItems})

The first stores the Combobox1 object into the collection.  The second stores the values selected into the collection.

If you have a table in a table, JSON will serialize it without an issue.

 

BUT, that still leads me to the following concern over your approach - how would you be representing table data in your csv?

 

Ex. If you have two records of :  {Column1 : 1, Column2: "A"}  and {Column1 : 2, Column2: "B"}

That would be represented in csv as:

1, A

2, B

 

But if you have two records with tables in them:   {Column1 : 1, Column2: ["A", "B", "C"}  and {Column1 : 2, Column2: ["D"]}

How would you represent that in csv?  The columns would not match.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

djg
Frequent Visitor

You are right @RandyHayes . I was setting the entire control as my collection instead of the content of the control. Thanks for correcting my path. Much appreciated.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,350)