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 collection from...
Power Apps
Unanswered

create collection from string

(0) ShareShare
ReportReport
Posted on by 34

Hello, i have multiple string looks like:

user;country;city

user1;country1;city1

I want to create collection with column user;country;city

Can You advise how to achive this ?

Categories:
  • TheRobRush Profile Picture
    11,128 Moderator on at

    I am just going to start off with this. Your strings are not the same, one contains commas, one contains semicolons, at end of the first there is multiple line breaks then second starts. This would be better if you  just have a string that is user;country;city;user2;country2;city2 etc then no matter how long that string is you can toss this on a button and get a collection from it

    ClearCollect(recordSet, 
     ForAll(Sequence(CountRows(Split(Label16,";"))/3,1,3) As recordGrab,
     {User: Last(FirstN(Split(Label16,";"),recordGrab.Value)).Value,
     Country: Last(FirstN(Split(Label16,";"),recordGrab.Value+1)).Value,
     City: Last(FirstN(Split(Label16,";"),recordGrab.Value+2)).Value}))

     

    Otherwise if the string is broken up liek in example with multiple separators you need something like this. It's much messier though

    ClearCollect(recordSet, 
     ForAll(Sequence(CountRows(Split(Substitute(Substitute(Substitute(Substitute(Label16.Text,",",";"),Char(13),";"),Char(10),""),";;",";"),";"))/3,1,3) As recordGrab,
     {User: Last(FirstN(Split(Substitute(Substitute(Substitute(Substitute(Label16.Text,",",";"),Char(13),";"),Char(10),""),";;",";"),";"),recordGrab.Value)).Value,
     Country: Last(FirstN(Split(Substitute(Substitute(Substitute(Substitute(Label16.Text,",",";"),Char(13),";"),Char(10),""),";;",";"),";"),recordGrab.Value+1)).Value,
     City: Last(FirstN(Split(Substitute(Substitute(Substitute(Substitute(Label16.Text,",",";"),Char(13),";"),Char(10),""),";;",";"),";"),recordGrab.Value+2)).Value}))
  • tomiapage1 Profile Picture
    34 on at

    Sorry , my mistake. in text i have only semicolons

  • TheRobRush Profile Picture
    11,128 Moderator on at

    the place a button, and make it's onselect

    ClearCollect(recordSet, 
     ForAll(Sequence(CountRows(Split(Label16,";"))/3,1,3) As recordGrab,
     {User: Last(FirstN(Split(Label16,";"),recordGrab.Value)).Value,
     Country: Last(FirstN(Split(Label16,";"),recordGrab.Value+1)).Value,
     City: Last(FirstN(Split(Label16,";"),recordGrab.Value+2)).Value}))
  • rubin_boer Profile Picture
    4,843 Super User 2024 Season 1 on at

    hi @tomiapage1 as an alternative:

     

    Lazy method:

    ClearCollect(
     _finalCollection,
     AddColumns(
     ClearCollect(_temCollection, Split(_String, Char(10))), 
     "User", Index(Split(Value,";"),1).Value,
     "Country", Index(Split(Value,";"),2).Value,
     "City", Index(Split(Value,";"),3).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 383 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 356

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard