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

Notifications

Announcements

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:
I have the same question (0)
  • 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,841 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard