Skip to main content

Notifications

Community site session details

Community site session details

Session Id : Z+9dktvE/aMtm89VodlG/4
Power Automate - Building Flows
Answered

Split Value and String

Like (0) ShareShare
ReportReport
Posted on 3 Feb 2024 12:11:43 by 49

Hi folks,

notitle.png

How can i split that to be numbers and letters separately? Like this '231129' 'Felicia Iliescu'

It always contains numbers and letters of different character length not like in the image.

'231129Felicia Iliescu' is my result of extracted text in power automate which is responded to power apps and i want to split that result.

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on 24 Mar 2024 at 09:26:10
    Re: Split Value and String

    Hi @Pabblo_96,

     

    @ManishSolanki highlighted this post to me after I created a video to do something similar https://youtu.be/_6f5UBpHhZ0

     

    In this video you will learn how to remove or keep characters, symbols or numbers in a string with 1 action.  For example, using your requirement we can use one select to keep the integers and another select to keep the non integers and return both strings with a join expression.

     

    DamoBird365_0-1711271938965.png

    Here is the flow in edit mode:

    DamoBird365_1-1711271992348.png

    FROM of the select is:

    chunk(outputs('Compose'),1) which turns your string into an array (as seen in the video)

     

    Note that text mode is enabled on the select MAP.

     

    to keep integers you can use if(isInt(item()),item(),'') which if isint is true, we output the integer, otherwise we output an empty string ''.

     

    to keep the non integers (i.e. the characters) you can use if(isInt(item()),'',item()) which if isint is true, we output the an empty string '' otherwise we output the non integer value.

     

    To get the string of both selects, you can use join(body('SelectIsInt'),'') or join(body('SelectString'),'')

     

    My video above will explain this in more detail and hopefully open up more ideas for efficiency too.


    Cheers
    Damien

    Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts. Thanks

  • Verified answer
    ManishSolanki Profile Picture
    15,085 Super User 2025 Season 1 on 04 Feb 2024 at 13:23:05
    Re: Split Value and String

    Hi @Pabblo_96 

     

    Here is the sample flow that will work for any number of character in order ID.

     

    I have stored the input string in compose action:

    ManishSolanki_0-1707051874815.png

    231129Felicia Iliescu

     

    Next, add "Select" action which takes each character and create an array of objects with 2 properties - IsNumeric and Value. We will use expression to create an array:

    ManishSolanki_1-1707052091657.png

    Below expression needs to be added in the expression box as highlighted in the above screenshot:

    range(1,length(outputs('Compose')))

    Following text/expression is used for key/value in Map parameter:

    Key Value
    IsNumeric
    isInt(take(outputs('Compose'),item()))
    Value
    take(outputs('Compose'),item())

     

    Now, we will filter the output of select action that contains only numeric values using "Filter array" action. Pass the output of Select action as input:

    ManishSolanki_2-1707052393136.png

    Click "Edit in advanced mode" and enter the below query:

    @equals(item()?['IsNumeric'], true)

     

    Post filtering, add compose action to get the required numeric value which will be the last element with IsNumeric as true in the output body of filter array action:

    ManishSolanki_3-1707052576476.png

    last(body('Filter_array'))?['Value']

     

    Finally, add another compose action to get the text value from the input string. We will replace the numeric value collected in compose action with empty string from original input string:

    ManishSolanki_4-1707052783937.png
    replace(outputs('Compose'),outputs('Compose_2'),'')

     

    The output of compose 2 action will give the numeric value and text part will be collected in compose 3 action.

     

     

    Output:

    ManishSolanki_5-1707052878907.pngManishSolanki_6-1707052897761.png

     

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

  • Pabblo_96 Profile Picture
    49 on 04 Feb 2024 at 12:08:23
    Re: Split Value and String

    Hi @Expiscornovus 

    No it's not a date value.

    I know i can do this that way but the problem is that sometimes order ID have 6 characters and sometimes 8. Same is with first name and last name, they are different always

  • Expiscornovus Profile Picture
    31,643 Most Valuable Professional on 03 Feb 2024 at 14:20:27
    Re: Split Value and String

    Hi @Pabblo_96,

     

    That first part looks a lot like a date value (in yyMMdd format)? In other words, is the first part the numbers always 6 characters long?

     

    In that case try this for the numbers part

    substring(variables('OrderID'), 0, 6)

     

    And this for the letters part

    slice(variables('OrderID'), 6)

     

    date_string_split.png

     

     

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard
Loading started