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 Automate / Format results for tex...
Power Automate
Answered

Format results for text and for numbers

(0) ShareShare
ReportReport
Posted on by 428

Hi All

 

I have two formulae one work well with numbers and other work well with texts how should i combine both formulae and make single so if its number it apply number formulae and if text it use text formulae

 

formulae for number: replace(replace(replace(replace(string(outputs('Compose1')),'[',''),']',''),'"',''),',','')

formulae for text: replace(replace(replace(replace(string(outputs('Compose1')),'[',''),']',''),'"',''),',',' ')

 

As my outputs('Compose1') contains both text and number 

Categories:
  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Ashok2,

     

    You might be able to check the string outputs of the Compose1 action with an IsInt function.

     

    Try something like:

    if(isInt(string(outputs('Compose1'))), 'number expression', 'string expression')

     

  • Ashok2 Profile Picture
    428 on at

    @Expiscornovus 

    So my compose give me output like this 

    "(“Test”) dated ",
    "13",
    " ",
    "June",
    " 20",
    "2",
    "1",
    "

    if i apply number expression it give me right input like 13 June 2021 but for my text expression which remove comma and keep space instead give me like this (“Test”) dated 13 June 20 2 1 

    I tried your way but no luck any way to deal this situation thanks

  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Ashok2,

     

    Thanks for sharing that example output.

     

    In this specific example you can probably also use a split on the comma. Since all the values are comma separated. And after that you can use a join to join it back together as a string (without the comma).

     

    I also used a slice to remove the last 3 characters and the first character (1, -3)

     

    Below is an example

     

     

     

    join(split(slice(outputs('Compose1'), 1, -3), '","'), '')

     

     

     

    split_join_withslice.png

     

    Below is my test

     

    split_join_withslice02.png

     

  • Ashok2 Profile Picture
    428 on at

    @Expiscornovus 

    Sorry getting below issue as output is in array forgot to mention format like ["(“Test”) dated ",
    "13",
    " ",
    "June",
    " 20",
    "2",
    "1",
    "]

    The template language function 'slice' expects its first parameter to be of type string. The provided value is of type 'Array'

  • Verified answer
    Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Ashok2,

     

    In that case you can convert it to string first and slice 2 extra characters from the string.

     

    Try this instead:

    join(split(slice(string(outputs('Compose1')), 2, -4), '","'), '')

     

  • Ashok2 Profile Picture
    428 on at

    Thank you it worked but one last question is there way to modify this formulae so if in format it contain some letter like SpecialText or SpecialText2 add space after that so now my SpecialText  is coming like  "SpecialTextTest" so it make it "SpecialText Test" and other word as well "SpecialText2Test" to "SpecialText2 Test"

  • Chriddle Profile Picture
    8,729 Super User 2026 Season 2 on at

    If your output is an array, you should treat it as such. No crazy string operations 😉

    Simply: join(outputs('Compose1'), '')

  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Ashok2,

     

    Because it is a string before you split it you can still use replace functions. Try something like below:

    join(split(slice(replace(string(outputs('Compose1')), 'SpecialText', 'SpecialText '), 2, -4), '","'), '')
  • Chriddle Profile Picture
    8,729 Super User 2026 Season 2 on at

    Hi @Expiscornovus I think @Ashok2 's original value is an array.
    Therefore making it a string and replacing "," is not a good idea 😱

    Just join it 😉

  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Chriddle,

     

    Totally agree, that a join is a lot easier. But I didn't want to change my original approach (before I knew it was an array). I thought that would get more confusing. 

     

    Btw, now with the additional requirement of replacing the text within each item of the array that single join would not be sufficient anymore 😉

     

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 315 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 267

#3
Henil Profile Picture

Henil 115

Last 30 days Overall leaderboard