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 Long String in...
Power Apps
Answered

Split a Long String in Table

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello, 

 

I have this long string that I want to convert into a table with two columns (name and price). I used ":" and ";" in the string so I wish these were the separators. So, the string, for example, is: "banana: 40; apple:50; coconut: 30;"

 

This way I want the name appear in a column and the price in the second one. I was able to develop a listbox where each "name: price" was in a row by using the Split function. So, do you know how can I do this? 

 

Does someone knows how I can do it?

Categories:
I have the same question (0)
  • madlad Profile Picture
    2,637 Moderator on at

    Hi! You could try something like:

     

    ForAll(
     Split(*YourString*, ";"),
     {
     Name: First(Split(ThisRecord.Value, ":")),
     Price: Last(Split(ThisRecord.Value, ":"))
     }
    )

     

    Placing this inside a Collect statement, or something similar, will return a table with the data formatted as you specified.

  • Verified answer
    Talha_Dar Profile Picture
    870 Super User 2024 Season 1 on at

    Hi @Anonymous,

     

    You can use the following code on a button or in the OnStart property of your application to create a collection from a string.

     

    ClearCollect(
     records,
     ForAll(
     Split(
     "banana: 40; apple:50; coconut: 30;",
     ";"
     ) ,
     If(
     !IsBlank(ThisRecord.Value),
     With(
     {
     record: Split(
     ThisRecord.Value,
     ":"
     )
     },
     {
     Name: First(record).Value,
     Price: Last(record).Value
     }
     )
     )
     )
    )

     

    Now, just use "records.Name" or "records.Price" on your listbox to populate them with the specific details.

     

    If you found my answer helpful, please consider giving it a thumbs-up or a like. Your feedback is greatly appreciated!

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you. It really worked. I just had to change the names to the real scenario and use gallery instead of datatable.

     

    Thank you.

  • Talha_Dar Profile Picture
    870 Super User 2024 Season 1 on at

    Thank you for the feedback! I'm glad to hear that the solution worked for you. If you found it helpful, please consider giving it a thumbs up. If you have any more questions or need further assistance, feel free to ask.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 476

#2
WarrenBelz Profile Picture

WarrenBelz 365 Most Valuable Professional

#3
Vish WR Profile Picture

Vish WR 339

Last 30 days Overall leaderboard