web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

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,430 Super User 2025 Season 2 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,430 Super User 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard