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 Apps
Unanswered

Split Collection

(0) ShareShare
ReportReport
Posted on by

Hi!

I am trying to split Collection 1 into Collection 2, basically in Collection 1 - Column 1 the value might contain multiple values, the request is to split those values into individual rows keeping the same ID number.

 

isaiaguillon86_0-1716552010827.png

 

Categories:
  • Rajkumar_M Profile Picture
    3,747 Moderator on at

    Hi @isaiaguillon86 

     

    Try this formula,

     

    To split a collection in PowerApps where values in a column contain multiple entries separated by commas and create a new collection with each value in its own row while retaining the same ID, you can use a combination of ForAll, Split, and Collect functions.

     

    Clear(Collection2);

    // Clear Collection2 if it already exists

    ForAll(

        Collection1,// Iterate over each row in Collection1

        ForAll(

            Split(

                Column1,

                ","

            ),// Split the Column1 value by comma

            Collect(

                Collection2,

                {

                    // Collect the split values into Collection2

                    Column1: Value,

                    // Use the split result for Column1

                    ID: ID// Keep the same ID

                }

            )

        )

    );

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

  • Rajkumar_M Profile Picture
    3,747 Moderator on at

    @isaiaguillon86 Additionally, use TrimEnds() function in that formula,

     


            Collect(

                Collection2,

                {

                    // Collect the split values into Collection2

                    Column1: TrimEnds(Value),

                    // Use the split result for Column1

                    ID: ID// Keep the same ID

                }

     

    The TrimEnds(Value) function is used to ensure that any leading or trailing whitespace is removed from the split results. This is a precaution to handle any accidental spaces that might be present around the values in the original data.

     

    However, if you are sure that there are no extra spaces around your values, you can simplify the formula by omitting the TrimEnds function.

  • MuhammadAizaz Profile Picture
    53 on at

    Hello @isaiaguillon86 ,

    Here is the tested code. just copy and paste.

     

    ClearCollect(table1, Table(
        {ID: 1232, Column1: "1599"},
        {ID: 1235, Column1: "1600,1605,1606"},
        {ID: 1233, Column1: "1602"},
        {ID: 1234, Column1: "1603"}
    ));

    ClearCollect(table2, {ID: "abc", Column1: "abc"});
    Clear(table2);
    ForAll(table1,
    With({parentRecord: ThisRecord},
    ForAll(Split(parentRecord.Column1,","),
    Patch(table2, Defaults(table2),
    {
        ID: parentRecord.ID,
        Column1: ThisRecord.Value
    }
    )

    )))

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 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 130

Last 30 days Overall leaderboard