cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
susannarae
Helper III
Helper III

ClearCollect not clearing out old selections when exporting to Excel

Hi all, hopefully you can help me because I'm stumped.

 

I have a gallery/pseudo-spreadsheet on an Enrollment App I'm building for our preschool program, and the supervisor would like to filter by classroom, then export certain fields of information (specifically the Caregivers' contact info) into Excel to share with teachers. I followed Daniel Christian's "Export CSV from PowerApps" video to a T, and it seemed like it was working; after hitting 'Submit' the gallery would only display kids' info from the chosen room number. However, when I try to export just that collection to Excel, all the other previously chosen room numbers' assigned kids pop up as well in the saved file, even though the gallery that displays the collection displays correctly. I'm not sure what I'm doing wrong, hopefully you all can help. Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

I added a ClearCollect to the 'Submit' Button but the error was still occurring. I then realized I never had a Clear for the ExportCSVVar collection. I added that in at the end of the 'Export' button and that seemed to do the trick! Thank you for your support, I appreciate it.

View solution in original post

2 REPLIES 2
BCLS776
Community Champion
Community Champion

The two screenshots you shared show the use of Collect, not ClearCollect. I don't know much else about your app, but consider these ideas:

  •  Unless there is another Clear or ClearCollect statement acting on the collection, each subsequent Collect will only add record(s) to the collection and no previous information will be deleted.
  • It is normal to use a Collect within a ForAll statement, as a way to add multiple records to a collection through looping. However, if that collection is never cleared, it will add in more and more records

It sounds like you may need to add a Clear statement after you are done using a collection, or a ClearCollect to ensure a collection is empty before you put more records into it.

I added a ClearCollect to the 'Submit' Button but the error was still occurring. I then realized I never had a Clear for the ExportCSVVar collection. I added that in at the end of the 'Export' button and that seemed to do the trick! Thank you for your support, I appreciate it.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,911)