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 / How to add a row to th...
Power Apps
Unanswered

How to add a row to the collection

(0) ShareShare
ReportReport
Posted on by 2

I am using the below code to add a row to the existing collection, but it is giving me error.

Please advise what correction should I do to achieve this: 

 

Clear(colSvcExportData);

ForAll(
    SupportSvcGallery.AllItems As SvcExportData,
    Collect(
        colSvcExportData,
        {
            RecoNo: SvcExportData.RecoNo,
            SvcDate: Text(SvcExportData.SvcDate,"dd-mm-yyyy"),
            Model: SvcExportData.Model,
            SerialNo: SvcExportData.SerialNo,
            SvcSMR: SvcExportData.SvcSMR,
            SvcRemarks: SvcExportData.SvcRemarks,
            SvcExpense: SvcExportData.SvcExpense,
            Customer: SvcExportData.Customer
        }
    )
);

//Below code to collection 1 row of total at the end

Set(
        colSvcExportDataAddRow,
        {
            RecoNo: "Total",
            SvcDate: " ",
            Model: " ",
            SerialNo: " ",
            SvcSMR: " ",
            SvcRemarks: " ",
            SvcExpense: Text(Sum(SupportSvcGallery.AllItems,SvcExpense),"##,##0.00"),
            Customer: " "
        }
   
);

//below code to Union/Join with main collection and last row
Collect(
    colSvcExportData,
{
            RecoNo: colSvcExportDataAddRow.RecoNo,
            SvcDate: " ",
            Model: " ",
            SerialNo: " ",
            SvcSMR: " ",
            SvcRemarks: " ",
            SvcExpense: colSvcExportDataAddRow.SvcExpense,
            Customer: " "

}
);
 
 
MIA27_0-1718562553626.png

 

Categories:
I have the same question (0)
  • rzuber Profile Picture
    552 Moderator on at

    @MIA27 - Try:

     

    Collect(
     colSvcExportData,
     {
     RecoNo: colSvcExportDataAddRow.RecoNo,
     SvcDate: " ",
     Model: " ",
     SerialNo: " ",
     SvcSMR: " ",
     SvcRemarks: " ",
     SvcExpense: Text(colSvcExportDataAddRow.SvcExpense, "##,##0.00"),
     Customer: " "
     }
    )

    Data types have to be the same.

     

  • MIA27 Profile Picture
    2 on at

    I tried, its the same error.

     

    Please note I not able to keep the same Data type.

    Therefore, I want all the column last row to blank blank and 

    One column last row to show Text "Total" and the last row of Column SvcExpense as

    Text(Sum(SupportSvcGallery.AllItems,SvcExpense),"##,##0.00"),
     
    I also tried to put 0 where number field was required as shown in below image, still the same error
    Note : I want to be keep blank not 0, still I tried, but no result erro
     
    MIA27_0-1718565134780.png

     

     
     
  • MIA27 Profile Picture
    2 on at

    Also tried below, but same issue 

     

    MIA27_1-1718565347435.png

     

  • rzuber Profile Picture
    552 Moderator on at

    OK.. So all columns in your collection have to be the same data type when you add a new row.

     

    If ID is a number, it must be a number in every record. If date is a date, it must be a date in every record. If you convert a column to text, you must convert it to text in every record.

     

    Make sure your data types for each column match what you are initializing in your collection. (The top Collect() call)

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 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard