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 / Create a Collection fr...
Power Apps
Answered

Create a Collection from a Texbox String

(0) ShareShare
ReportReport
Posted on by 49

Hi,

I have a requirement to create a collection from a textbox. For example, the text in the textbox would look something like this:

RP1234 | RP1235 | RP1236. All items are separated by the "|" character. I've tried using the Split() function but cannot get it to work!

 

Your help would be greatly appreciated.

 

Thanks,

Bluenose

Categories:
  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    You would use Split(TextBoxX.Text, "|") and then use the Result.

     

    split1.png

     

    split.png

  • rubin_boer Profile Picture
    4,843 Super User 2024 Season 1 on at

    hi @Bluenose as per @JR-BejeweledOne wrap it all into that collection of yours ClearCollect(_yourCollection,Split("RP1234 | RP1235 | RP1236","|").Result) 😉

  • Abhilash_Swain Profile Picture
    901 on at

    Hi @Bluenose ,
    Please use this formula in a  Button > On Select Property
    ClearCollect(testcollect, Split(Label7.Text,"|")) for Label control 
    ClearCollect(testcollect, Split(TextInput1.Text,"|")) for text control

     

     

    Please give me a Thumbs up if I answered your question and mark it as a solution to help others.

    Thanks

    Abhi

  • Nogueira1306 Profile Picture
    7,390 Super User 2024 Season 1 on at

    Nogueira1306_0-1646674362859.png

    Nogueira1306_1-1646674378412.png

     

     

    ForAll(Split(Label11.Text, " | "),
    Collect(CollectionTest,{Value: Result}))

     

    If you need additional help please tag me in your reply and please like my reply.
    If my reply provided you with a solution, pleased mark it as a solution ✔️!

    Best regards,

    Gonçalo Nogueira

    Check my LinkedIn!

    Buy me a coffee!

    Check my User Group (pt-PT)!

    Last Post on Community

    My website!

     

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Bluenose 

    So many choices!!

     

    My added bit would be to deal with the spaces outside of the split.

    ClearCollect(yourCollection, 
     ForAll(Split(Label11.Text, "|"), Trim(Result))
    )

     

    Or, to reduce the overhead of the heavy-weight collection which is not needed (unless you have some need to perform add/remove/update functions on the results):

    Set(splitItems, 
     ForAll(Split(Label11.Text, "|"), Trim(Result))
    )

     

    As @JR-BejeweledOne pointed out, you don't need to duplicate it into a collection - it can simply be used on any control that has an Items property.

     

    @Nogueira1306 Your ForAll is used backward - ForAll is a function that produces a table.  It takes two parameters, the table to iterate over and the schema for the record to be produced.  In your formula, your Collect statement is returning a table of the collection and putting it in each iteration in a Value column as the result of the ForAll.

    Also since if no column is specified, then Value will be assumed - there is no need to specify the Value column.

    The above formulas both produce tables that have a Value column (because it is not specified).

     

    I hope this is helpful for you.

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard