web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Unable to export galle...
Power Apps
Unanswered

Unable to export gallery items to CSV

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

 

After watching a youtube tutorial (https://www.youtube.com/watch?v=QTbVMu6DIfQ&t=2s) on how to export filtered data to a CSV file, I tried replicating it for my app. However, the output is inconsistent. 

 

These are the steps I followed:

  1. Created an empty variable to store my CSV data
  2. Created a collection to store all labels of each item from my gallery as individual rows
  3. Concatenated each item of the collection with a comma and saved it to the variable I created in Step 1. ( I also concatenated column names in the beginning to reflect as headers in my CSV file)
  4. I created a flow with a manual powerapps trigger, which creates a sharepoint file in a fixed location.
  5. CSV file generated

Following is the code:

 

Set(ExportCSVVar,"");
ForAll(ExportGallery.AllItems,Collect(
ExportCSVCol,{
TaskID:TaskID_Gal.Text,
RequestorSite:RequestorSite_Gal.Text,
RequestorDepartment:RequestorDepartment_Gal.Text,
CostCenterCode:CostCenterCode_Gal.Text,
RequestorName:RequestorName_Gal.Text,
RequestorEmail:RequestorEmail_Gal.Text,
TaskType:TaskType_Gal.Text,
BillingType:BillingType_Gal.Text,
TaskPriority:TaskPriority_Gal.Text,
TaskTitle:TaskTitle_Gal.Text,
TaskDescription:TaskDescription_Gal.Text,
TaskJustification:TaskJustification_Gal.Text,
TaskStatus:TaskStatus_Gal.Text,
ReferenceNumber:ReferenceNumber_Gal.Text,
FinancialImpact:FinancialImpact_Gal.Text,
FICurrency:FICurrency_Gal.Text,
Resource_TO:Resource_TO_Gal.Text,
Resource_TO_email:Resource_TO_email_Gal.Text,
Resource_AQE:Resource_AQE_Gal.Text,
Resource_AQE_email:Resource_AQE_email_Gal.Text,
Resource_RA:Resource_RA_Gal.Text,
Resource_RA_email:Resource_RA_email_Gal.Text,
Resource_PKG:Resource_PKG_Gal.Text,
Resource_PKG_email:Resource_PKG_email_Gal.Text,
Resource_BML:Resource_BML_Gal.Text,
Resource_BML_email:Resource_BML_email_Gal.Text,
OpenDate:OpenDate_Gal.Text,
DueDate:DueDate_Gal.Text,
ExpectedBackOrderDate:ExpectedBackOrderDate_Gal.Text,
AssignDate:AssignDate_Gal.Text,
CloseDate:CloseDate_Gal.Text,
Stakeholders:Stakeholders_Gal.Text,
StakeholdersEmail:StakeholdersEmail_Gal.Text,
Coordinator:Coordinator_Gal.Text
}
));

Set(
ExportCSVVar,
"Task ID,Requestor Site,Requestor Department,CostCenter Code,Requestor Name,Requestor Email,Task Type,Billing Type,Task Priority, Task Title,Task Description,Task Justification,Task Status,Reference Number,Financial Impact,FI Currency,Resource TO,Resource TO_email,Resource AQE,Resource AQE_email,Resource RA,Resource_RA_email,Resource PKG,Resource PKG_email,Resource BML,Resource BML_email,Open Date,Due Date,Expected BackOrderDate,Assign Date,Close Date,Stakeholders,Stakeholders Email,Coordinator,"
& Char(10) & Concat(ExportCSVCol,
TaskID&","&RequestorSite&","&RequestorDepartment&","&CostCenterCode&","&RequestorName&","&RequestorEmail&","&TaskType&","&BillingType&","&TaskPriority&","&TaskTitle&","&TaskDescription&","&TaskJustification&","&TaskStatus&","&ReferenceNumber&","&FinancialImpact&","&FICurrency&","&Resource_TO&","&Resource_TO_email&","&Resource_AQE&","&Resource_AQE_email&","&Resource_RA&","&Resource_RA_email&","&Resource_PKG&","&Resource_PKG_email&","&Resource_BML&","&Resource_BML_email&","&OpenDate&","&DueDate&","&ExpectedBackOrderDate&","&AssignDate&","&CloseDate&","&Stakeholders&","&StakeholdersEmail&","&Coordinator&","&Char(10))
)

 

I am facing problems. The output is inconsistent. Please refer to the screenshots. The collection is getting created accurately (refer to the temporary table) but the CSV file is misplacing many values. Also, it is showing blank values for many entries.

 

Screenshot (270).png

 

Screenshot (272).png

 

Can anyone help? Also, please tag Daniel Christian who created the youtube video.

 

Regards,

Aakash

 

 

Categories:
  • eka24 Profile Picture
    20,925 on at

    Check these colored lines. It shouldnt be part
    Set(
    ExportCSVVar,
    "Task ID,Requestor Site,Requestor Department,CostCenter Code,Requestor Name,Requestor Email,Task Type,Billing Type,Task Priority, Task Title,Task Description,Task Justification,Task Status,Reference Number,Financial Impact,FI Currency,Resource TO,Resource TO_email,Resource AQE,Resource AQE_email,Resource RA,Resource_RA_email,Resource PKG,Resource PKG_email,Resource BML,Resource BML_email,Open Date,Due Date,Expected BackOrderDate,Assign Date,Close Date,Stakeholders,Stakeholders Email,Coordinator,"
    & Char(10) & Concat(ExportCSVCol,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @eka24 ,

     

    They are the headers. With or without them, the output is still inconsistent.

     

    Regards,

    Aakash 

  • eka24 Profile Picture
    20,925 on at

    The last line Coordinator&","&Char(10))
    should be
    Coordinator&Char(10))

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @eka24  I tried that but it didn't work as well.

  • eka24 Profile Picture
    20,925 on at
    I have used same video to produce results. If you really want to follow the video, the the last reply I gave is valid. Unless you are not following the video.
    Kindly remove the header I colored and also correct using my last reply and see the results.
  • eka24 Profile Picture
    20,925 on at
    I have used same video to produce results. If you really want to follow the video, then the last reply I gave is valid.
    Kindly remove the header I colored and also correct using my last reply and see the results.
  • timl Profile Picture
    37,287 Super User 2026 Season 2 on at

    Hi Aakash

    This is the type of problem that can occur if some of the field values in your input data contains commas or new lines. This would corrupt the CSV output.

    The solution to this would be to call the substitute function to remove those characters, or to delimit values that contain a comma with double quotes.

    The row that relates to task T-0007 seems to be where it starts to go wrong. Can you confirm the data values for this row?

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @timl ,

     

    Thanks for replying. I guess you are correct. I have substituted comma with blank space. However, the issue persists. What are the other delimiters apart from comma that could be responsible? Here is my sample code:

     

    Substitute(ThisItem.BillingType,",","")

     

    Regards,

    Aakash

  • timl Profile Picture
    37,287 Super User 2026 Season 2 on at

    Hi @Anonymous 

    The new line characters could also be a problem because they would be the characters that indiciate a 'new row'.

    Therefore, substituting Char(10) and Char(13) might take you closer to fixing this.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @eka24  I did as you suggested

    @timl I substituted the delimiters as you suggested 

    Substitute(Substitute(Substitute(ThisItem.TaskDescription,",",""),Char (10)," "),Char (13)," ")

     

    Unfortunately, it didn't influence the output.

     

    I am also wondering that even if I missed to substitute some delimiters, at least the entries should have moved to the next cell, right? Right now, more than 50% of the cells are empty which shouldn't be the case.

     

    What are your thoughts?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard