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 / Split a row in a colle...
Power Apps
Answered

Split a row in a collection into multiple rows based on value in column

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi everyone,

 

I have the following situation: 

 

We have a SQL-database that contains timesheet entries. The columns are the following:

assignment_id , entry_date , update_date , hours , comment

 

In PowerApps I create a collection that looks like this:

Gnashy_0-1675347037826.png

 

The comment is build up like this:

[#102;1,5;qqqqqq]

 

#102: This is the user story number (not to be confused with ID) - 1357 is the corresponding ID of this number

1,5: Number of hours

qqqqqqq: description

 

Now here comes the hard part. It can occur that the comment contains multiple user stories like:

[#102;1,5;qqqqqq][2;3;Test]

 

I would like to split the collection if this occurs. Desired outcome:

 

UserStoryId ,  UserStoryName , assignment_id , comment                 , entry_date , hours, update_date

1357              Task 1                      72646             [#102;1,5;qqqqqq]      2/2/2023      1,5       2/2/2023

1358              Task 2                      72646             [2;3;Test]                      2/2/2023       3        2/2/2023

 

How can one achieve this?

Categories:
  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

    Okay, the sign of the splitting thing is the nothing, right?

    If so, I think you'd better add a delimiter between each [], like a ^ or other delimiters differs from ";" and comma ",".

     

    Or you could firstly replace all the "][" with "],[", here is how I achieve this.

    1). Create a collection to replace all the "][" with "],[":

    ClearCollect(coooo,ForAll(YourCollection,Substitute(Comment,"][","],[")))

    2). Then generate another collection as below:

    Clear(Collection2);ForAll(coooo, ForAll(Split(Value,"^"),Collect(Collection2,{Comment:Result})));
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi v-qiaqi-msft,

     

    I found a workaround, but I got another request to not only accept "][" but also "}{", "}[" or "]{" and that is where I am stuck, since I want to use the solution you proposed earlier to add the delimiter like ^ between them. 

     

    When I try this, it only gives me the result of the comment and not the rest of the attributes I need. Perhaps I am doing something wrong.

    Clear(Collection2);ForAll(coooo, ForAll(Split(Value,"^"),Collect(Collection2,{Comment:Result})));

     

    This is my formula now: 

     

     Clear(colTimesheetEntries);
     ForAll(
     varTimesheetEntries As _entry,
     ForAll(
     Split(
     _entry.comment,
     "]["
     ) As _comment,
     With(
     {
     varValues: Split(
     Substitute(
     Substitute(
     _comment.Result,
     "[",
     ""
     ),
     "]",
     ""
     ),
     ";"
     )
     },
     Collect(
     colTimesheetEntries,
     {
     Date: _entry.entry_date,
     Project: _entry.Project,
     Hours: Coalesce(
     Last(
     FirstN(
     varValues,
     2
     )
     ).Result,
     _entry.hours
     ),
     Comment: Coalesce(
     Last(varValues).Result,
     _comment.Result
     )
     }
     )
     )
     )
     );

     

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 250

#3
Mohsin Ali Profile Picture

Mohsin Ali 225

Last 30 days Overall leaderboard