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 a string int...
Power Apps
Answered

Splitting a string into a table

(0) ShareShare
ReportReport
Posted on by 170

Here is some sample data that is being returned by a flow for the power app:

HALLE CHRISTOPHE EDWARDSON###80110720###D/E-PROTECTION FROM HAZARDS###46369;HALLE CHRISTOPHE EDWARDSON###80110722###D/E-PROTECT MIN COVER NOT MET###46170;
HALLE CHRISTOPHE EDWARDSON###80110724###D/E-ANODE & ANODE GRND BED CATH###45667;
 
I split the string by ";" and it seems to work fine as I can see each "record" in the Value from the Split.  But what I need to do now is to create a table with these records.  So in the above example, I need a table such as:
 
NameQual IDQualDate
HALLE CHRISTOPHE EDWARDSON80110720D/E-PROTECTION FROM HAZARDS46369
HALLE CHRISTOPHE EDWARDSON80110722 D/E-PROTECT MIN COVER NOT MET46170
HALLE CHRISTOPHE EDWARDSON
80110724D/E-ANODE & ANODE GRND BED CATH45667

 

What would be the best way to do this?  Also, the "Date" field are those Excel Date Values that I believe I can convert at the power automate level, or is there a way to do that here?

 

Thanks for the information

Categories:
I have the same question (0)
  • Verified answer
    AaronKnox Profile Picture
    514 Super User 2024 Season 1 on at

    Hi @CMSGuy ,

    The solution is to ForAll() through your initial Split() and construct the table via Collect().  To convert the Excel date you need to use the DateAdd() function.  To prevent a blank line I added the With() to trim the last semicolon.  Putting it all together:

     

     

    With({_OriginalString: "HALLE CHRISTOPHE EDWARDSON###80110720###D/E-PROTECTION FROM HAZARDS###46369;HALLE CHRISTOPHE EDWARDSON###80110722###D/E-PROTECT MIN COVER NOT MET###46170;HALLE CHRISTOPHE EDWARDSON###80110724###D/E-ANODE & ANODE GRND BED CATH###45667;"},
     UpdateContext({locStringFromFlow: Left(_OriginalString,Len(_OriginalString) - 1)})
    );
    
    Clear(colTransposeStringToATable);
    
    ForAll(Split(locStringFromFlow,";"),
     Collect(colTransposeStringToATable,{
     Name:Index(Split(ThisRecord.Value,"###"),1).Value,
     'Qual ID':Index(Split(ThisRecord.Value,"###"),2).Value,
     Qual:Index(Split(ThisRecord.Value,"###"),3).Value,
     Date: 
     Text( DateAdd(Date(1900,1,1), 
     Index(Split(ThisRecord.Value,"###"),4).Value -2 ),DateTimeFormat.LongDate)
     }
     )
    )

     

     

    Capture10a.PNG

     

    Hope this helps!

    Aaron

  • Verified answer
    iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Hey @CMSGuy 

     

    Took a bit of experimenting to get it right, but we can essentially double split it and remove blanks, then for each split-split we trim out non-valid characters like line feed and carriage return using Regex matching, and then for the Qual we keep all the Other special characters

     

    image.png

     

    Code for that button (which just sets a variable - that I then use as the Items for that gallery):

    Set(gblSplitTable,
     ForAll(
     RemoveIf(Split(Trim(TextToCheck.Text),";"), Value="") As OuterColumns,
     With(
     {
     InnerColumns: Split(OuterColumns.Value, "###")
     },
     {
     Name: Concat(Split(Last(FirstN(InnerColumns.Value, 1)).Value, ""),
     If(IsMatch(Value, "[a-zA-Z0-9 ]"), Value)),
     QualID: Concat(Split(Last(FirstN(InnerColumns.Value, 2)).Value, ""), 
     If(IsMatch(Value, "[0-9 ]"), Value)),
     Qual: Concat(Split(Last(FirstN(InnerColumns.Value, 3)).Value, ""),
     If(IsMatch(Value, "[ a-zA-Z$&+,:;=?@#|'<>.^*()%!/-]"),Value)),
     Date: If(Len(Concat(Split(Last(FirstN(InnerColumns.Value, 4)).Value, ""),
     If(IsMatch(Value, "[0-9 ]"),Value)))>0,
     // Dates as Numbers in Excel use 1899-12-30 as initial to add to 
     // (so subtract 2 from 1900-01-01 [earliest PowerApps Date function value]) 
     Text(DateAdd(
     Date(1900, 1, 1), 
     Value(Concat(Split(Last(FirstN(InnerColumns.Value, 4)).Value, ""), If(IsMatch(Value, "[0-9]"),Value))) - 2,
     TimeUnit.Days),
     "[$-en-US]dd/mm/yy"
     ),
     Blank())
     }
     )
     )
    )

     

    Have also attached a proof of concept app where you can play around with what I've created and transfer what you need to your code 🙂

     

    Cheers,

    Sancho

  • WK-23070617-0 Profile Picture
    on at

    Great, took me a while to figure it out and to adapt it into my solution.

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 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard