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 / Splitting Variable to ...
Power Apps
Answered

Splitting Variable to Collection

(0) ShareShare
ReportReport
Posted on by 29

Trying to split a variable into a collection like the example below

 

Variable

Header1:Data1\nHeader2:Data2\nHeader3:Data3\n........Header30:Data30

 

Require Collection

Header1Header2Header3Header30
Data1Data2Data3Data30

 

Data may possibly have a ':' within it but Header never will.

 

Any help would be appreciated 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,290 Most Valuable Professional on at

    Hi @MikeSwerve ,

    The issue is that you cannot dynamically create field names. The code below will separate it all and if you put it in a gallery with a wrap count of 2, it looks like yours transposed, but that is the best you will do.

    With(
     {
     wSplit: 
     Split(
     YourTextHere,
     "\n"
     )
     },
     ClearCollect(
     colSplit,
     Ungroup(
     ForAll(
     wSplit,
     Split(
     Result,
     ":"
     )
     ),
     "Value"
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

     

     

     

  • MikeSwerve Profile Picture
    29 on at

    Thanks WarrenBelz, that's not really the outcome I wanted.

     

    If I had the 2 records come in as 

    Record 1 - Header

    Header1|||Header2|||Header3|||.....Header30

     

    Record 2 - Data

    Data1|||Data2|||Data3|||.....Data30

     

    And display it in a gallery as below

    Header1      Data1
    Header2      Data2
    Header3      Data3
    Header30     Data30

     

     

     

     

     

  • WarrenBelz Profile Picture
    155,290 Most Valuable Professional on at

    @MikeSwerve ,

    Correct - that is exactly the result I received testing it. As I said, you cannot create field/column names dynamically.

  • MikeSwerve Profile Picture
    29 on at

    Sorry WarrenBelz, I didnt set the text wrap to 2.

     

    Some of the data has a ':' in it and its splitting those also, is there a way to split  at the first ':' after every '\n'

  • Verified answer
    WarrenBelz Profile Picture
    155,290 Most Valuable Professional on at

    @MikeSwerve ,

    One thing about delimited data is you have to make it consistent - for instance CSV files cannot contain any commas other than between fields. The problem is (with a bit of code gymnastics), you might be able to get the first part before the split, but you want the whole piece.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

     

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,045

#2
Valantis Profile Picture

Valantis 675

#3
11manish Profile Picture

11manish 592

Last 30 days Overall leaderboard