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 / Export to excel output...
Power Apps
Answered

Export to excel outputs repeated information.

(0) ShareShare
ReportReport
Posted on by 426

Hi i have two galleries, Main gallery A & nested sub gallery B. The idea is to export the information into CSV so i proceeded to create a collection to gather the gallery information shown below and export it to csv. It worked but im getting a repeated information in the csv table. Collection name is CsesAll. i set a code on the navigate button as below

ForAll(GalleyA.AllItems,Collect(CsesAll,{SAPID:Label21.Text,RequestorName:Label3_15,Vendor:Label23.Text,DateStart:Label8_30.Text,DateEnd:Label8_31,TotalFees:Label8_21,CostCentre:Label24,Evalcomplete:Label17.Text}));Navigate(ExportScreen)

 

THis navigates to the export screen and here Export button runs the flow -> ForAll(GalleyA.AllItems,Collect(CsesAll,{SAPID:Label21.Text,RequestorName:Label3_15,Vendor:Label23.Text,DateStart:Label8_30.Text,DateEnd:Label8_31,TotalFees:Label8_21,CostCentre:Label24,Evalcomplete:Label17.Text}));Set(varcsv,Concat(CsesAll,SAPID & "," & RequestorName & "," & Vendor & "," & DateStart & "," & DateEnd & "," & TotalFees & "," & CostCentre & "," & Evalcomplete& Char(10)));ExportCseAll.Run(varcsv,"External Training Records" & Now()).

Good news export works but I dont get the headers and the information is repeated in the same exported csv.

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,100 Most Valuable Professional on at

    Hi @nchandran ,

    You will see the headers I have added - also you need to refer to the gallery rows as below - I have also got rid of a Variable and Collection "hanging around"

    With(
     {
     wGal:
     ForAll(
     GalleyA.AllItems As aGal,
     {
     SAPID: aGal.Label21.Text,
     RequestorName: aGal.Label3_15,
     Vendor: aGal.Label23.Text,
     DateStart: aGal.Label8_30.Text,
     DateEnd: aGal.Label8_31,
     TotalFees: aGal.Label8_21,
     CostCentre: aGal.Label24,
     Evalcomplete: aGal.Label17.Text
     }
     )
     },
     With(
     {
     wCSV:
     "SAPID,RequestorName,Vendor,DateStart,DateEnd,TotalFees,CostCentre,Evalcomplete" & Char(10) & 
     Concat(
     wGal,
     SAPID & "," & RequestorName & "," & Vendor & "," & DateStart & "," & 
     DateEnd & "," & TotalFees & "," & CostCentre & "," & Evalcomplete & Char(10)
     )
     },
     ExportCseAll.Run(
     wCSV,
     "External Training Records" & Now()
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • nchandran Profile Picture
    426 on at

    I think there was a missing ':' after wCSV fixed it. its not able to pick the label from the nested gallery b how can we fix it. After removing the nested gallery b label it worked but it only imported gallery A data. I need the subgallery colum which is Evalcomplete.

  • WarrenBelz Profile Picture
    156,100 Most Valuable Professional on at

    Hi @nchandran ,

    Typo fixed (dangers of free-typing code).

    Which Labels are in the nested gallery ? Also what is the relationship between the nested gallery and the main gallery record it sits in ? Your problem here is a one-to-many relationship with the main gallery, so you can only (at best) pick up the first (or last) item from the nested item.

  • nchandran Profile Picture
    426 on at

    Hi @WarrenBelz ,

    Typo fixed (dangers of free-typing code). -sign of a genius😃

    Which Labels are in the nested gallery ? only one for now which is  Evalcomplete: Label17 shows the evaluation status from the secondary source feeding the nested sub gallery.

    Also what is the relationship between the nested gallery and the main gallery record it sits in ? 

    Main gallery is for registered courses, nested sub gallery shows evaluation done for thoses course .

    In addition nested gallery source got a column called master ID which populates the same number as the ID from main gallery this allows me to retreive the related data. Items on nested gallery its like Filter(HRExtEval,MasterID =ThisItem.ID)

    Your problem here is a one-to-many relationship with the main gallery, so you can only (at best) pick up the first (or last) item from the nested item. : Thats the reason initially i did a collection of both galleries but found it too complicated and it was delivering the same repeated table.

  • Verified answer
    WarrenBelz Profile Picture
    156,100 Most Valuable Professional on at

    Hi @nchandran ,

    You would have been better defaulting the same formula in a Text control or Lable in the gallery if only a single value is returned, but try this (I have assumed the field name here)

    With(
     {
     wGal:
     ForAll(
     GalleyA.AllItems As aGal,
     {
     SAPID: aGal.Label21.Text,
     RequestorName: aGal.Label3_15,
     Vendor: aGal.Label23.Text,
     DateStart: aGal.Label8_30.Text,
     DateEnd: aGal.Label8_31,
     TotalFees: aGal.Label8_21,
     CostCentre: aGal.Label24,
     Evalcomplete: 
     LookUp(
     HRExtEval,
     MasterID = aGal.ID
     ).'Evaluation Status'
     }
     )
     },
     With(
     {
     wCSV:
     "SAPID,RequestorName,Vendor,DateStart,DateEnd,TotalFees,CostCentre,Evalcomplete" & Char(10) & 
     Concat(
     wGal,
     SAPID & "," & RequestorName & "," & Vendor & "," & DateStart & "," & 
     DateEnd & "," & TotalFees & "," & CostCentre & "," & Evalcomplete & Char(10)
     )
     },
     ExportCseAll.Run(
     wCSV,
     "External Training Records" & Now()
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

  • nchandran Profile Picture
    426 on at

    @WarrenBelz ,

    Completely forgot about the lookup function, something new from this topic. Can i confirm what you did, you actually took one variable to capture the gallery columns into headers and another variable to output into the flow..correct me if I'm wrong here.

  • WarrenBelz Profile Picture
    156,100 Most Valuable Professional on at

    Hi @nchandran ,

    Yes - also the With() statement can be nested or chained (as in this example) and saves Collections or Variable hanging around slowing your app. I have a blog on the subject if it is useful to you.

  • nchandran Profile Picture
    426 on at

    @WarrenBelz  Thank you for enlightening me with this information.

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 96 Super User 2026 Season 1

Last 30 days Overall leaderboard