web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : xQr0UBbeTYjrOkn38UNxog
Power Apps - Building Power Apps
Answered

Split string into collection

Like (0) ShareShare
ReportReport
Posted on 26 Aug 2022 08:12:25 by

Hi,

I want to split a string from label and store it in a collection, i also want to add indexes to splitted text.

Example:

My label("Resulting_Text"is the name of the label) looks like this "E123a E143b E156f". I want my collection to have 2 columns("Index" and "Value" are the names of the columns).

Collection should look like this:

Index     Value

0            E123a

1            E143b

2            E156f

 

Pls help

Thank you

Categories:
I have the same question (0)
  • rugitola Profile Picture
    5 on 12 Jul 2023 at 20:56:54
    Re: Split string into collection

    I replaced 

    ).Result

    with 

    ).Value

    and working perfectly now.   Thanks for the solution @timl!

  • rugitola Profile Picture
    5 on 12 Jul 2023 at 14:13:15
    Re: Split string into collection

    @timl  If I use your formula as-is (or changing to my label control) it presents the error:
    The function 'AddColumns' has some invalid arguments

    Any thoughts why this might be the case?

  • NidjoJohnny22 Profile Picture
    288 on 11 Jul 2023 at 13:53:17
    Re: Split string into collection

    @timl thank you for quick reply! I understand it now 🙂 

  • timl Profile Picture
    35,437 Super User 2025 Season 2 on 10 Jul 2023 at 19:17:51
    Re: Split string into collection

    @NidjoJohnny22 

    That's the part that retrieves the value (eg, E123a). The Split function splits the input into rows so the call to index is required to retrieve the corresponding value by ordinal number.

  • NidjoJohnny22 Profile Picture
    288 on 10 Jul 2023 at 13:44:41
    Re: Split string into collection

    Hi @timl , I don't understand what does the last part of the AddColumns() function do?

    Index( data, Index ).Result

  • timl Profile Picture
    35,437 Super User 2025 Season 2 on 26 Aug 2022 at 10:56:19
    Re: Split string into collection

    You're welcome @Anonymous - glad to help!

  • Community Power Platform Member Profile Picture
    on 26 Aug 2022 at 10:16:30
    Re: Split string into collection

    @timlyou are a life savior. Thanks!!!

     

  • Verified answer
    timl Profile Picture
    35,437 Super User 2025 Season 2 on 26 Aug 2022 at 09:19:13
    Re: Split string into collection

    @Anonymous 

    Here's a formula to do this:

    ClearCollect(
     yourCollection,
     With(
     {
     data: Split(
     "E123a E143b E156f",
     " "
     )
     },
     AddColumns(
     RenameColumns(
     Sequence(CountRows(data)),
     "Value",
     "Index"
     ),
     "Value",
     Index(
     data,
     Index
     ).Result
     )
     )
    )

    With the formula above, you would substitute the hardcoded value "E123a E143b E156f" with a reference to your label control (eg label1.Text).

     

  • StretchFredrik Profile Picture
    3,132 Super User 2025 Season 2 on 26 Aug 2022 at 08:31:14
    Re: Split string into collection

    If you want a collection try looking at this thread:

     

    https://powerusers.microsoft.com/t5/Building-Power-Apps/split-string-into-collection/td-p/764556

  • StretchFredrik Profile Picture
    3,132 Super User 2025 Season 2 on 26 Aug 2022 at 08:28:53
    Re: Split string into collection

    Is there any reason you need a collection?

     

    You can create records with the help of a varabile: 

    StretchFredrik_0-1661502519296.png

     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading started
Loading complete