Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

How to add a row to the collection

(0) ShareShare
ReportReport
Posted on by

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

 

  • rzuber Profile Picture
    545 Super User 2025 Season 1 on at
    Re: How to add a row to the collection

    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)

  • MIA27 Profile Picture
    on at
    Re: How to add a row to the collection

    Also tried below, but same issue 

     

    MIA27_1-1718565347435.png

     

  • MIA27 Profile Picture
    on at
    Re: How to add a row to the collection

    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

     

     
     
  • rzuber Profile Picture
    545 Super User 2025 Season 1 on at
    Re: How to add a row to the collection

    @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.

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,708 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,030 Most Valuable Professional

Leaderboard