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 / expression to format a...
Power Automate
Unanswered

expression to format a value

(0) ShareShare
ReportReport
Posted on by 188

Hi there, 

 

I have a flow that captures a user input, the expected input is "LH" and then some digits. For example, LH12345 or LH123456.

 

I have a flow that consumes this user input, but sometimes the user inputs just the digits, an example:  "12345" or "123456".
Or, sometimes users include a space, LH 12345 etc. This causes my flow to fail, as it is expecting it to start with "LH" and for there to be no spaces.

 

How would I write an expression that checks if: 1. If it does not start with LH, then add that in and or, remove any spaces?

Categories:
I have the same question (0)
  • Chriddle Profile Picture
    8,591 Super User 2026 Season 1 on at

    Here outputs('Compose') is the number to check. If your number is already a string you can remove the string function.

    Note that "LH" is case-sensitive here:

    replace(
     if(
     equals(
     substring(string(outputs('Compose')), 0, 2), 'LH'),
     outputs('Compose'),
     concat('LH', string(outputs('Compose'))
     )
     ),
     ' ',
     ''
    )

     

  • drossi90 Profile Picture
    188 on at

    Thanks @Chriddle , that looks good.

    And if it's "lh", how would we overcome that to not be case-sensitive?

  • Chriddle Profile Picture
    8,591 Super User 2026 Season 1 on at

    Use toUpper() before comparison:

    replace(
    	if(
    		equals(
    			substring(toUpper(string(outputs('Compose'))),0,2),
    			'LH'
    		),
    		toUpper(outputs('Compose')),
    		concat('LH', string(outputs('Compose')))
    	),
    	' ',
    	''
    )

      

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!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 77 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 68

#3
Expiscornovus Profile Picture

Expiscornovus 56 Most Valuable Professional

Last 30 days Overall leaderboard