cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BenderMatt
Frequent Visitor

Remove Leading Zeros

Hi everyone!

 

I'm looking for an expression that has the ability to look at a string and eliminate leading zeros.  0000017856 to become 17856.  Can anyone assist?

 

I greatly appreciate it!

1 ACCEPTED SOLUTION

Accepted Solutions

Much more effective approach you'll find here.

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.

View solution in original post

9 REPLIES 9
jinivthakkar
Super User
Super User

@BenderMatt please find my flow, which replaces 0 with blank values.

 

jinivthakkar_1-1612331326656.png

jinivthakkar_2-1612331382074.png

jinivthakkar_3-1612331439935.png

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

jinivthakkar
Super User
Super User

@BenderMatt There is one issue with  my solution is that if the string has 0 anywhere it will removed, so assuming that you will have first 5 characters as 0 and you only need characters after that, we can use substring which will give us correct results even if the later part of the string has 0.

 

jinivthakkar_4-1612331786396.png

jinivthakkar_5-1612331824733.png

This does not remove 0 from the latter part of the string.

 

Expression to truncate first 5 characters : 

 

substring(variables('varZero'),5)

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

 

Much more effective approach you'll find here.

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.
BenderMatt
Frequent Visitor

Thank you all, for the help!  That got it!

 

BenderMatt_0-1612538483550.pngBenderMatt_1-1612538551777.png

 

VictorIvanidze
Community Champion
Community Champion

Glad to help.

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.

using float() was the simplest solution that worked for me

does not work, for values that have zero in the value and bring characters:
- '0000023034'
- '0ABC0D'

in this case how would you apply

VictorIvanidze
Community Champion
Community Champion

Hi @RamiroMatos,

did you test this

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.
TimVW
Regular Visitor

Based on this original question/answer I used a Do Until with a check using string function StartsWith: startsWith(variables('TEST'),'0') is not equal to 'true'.

Instead of the check on: first(variables('TEST')) is not equal to 0, which only worked for removing a zero once.

This change resulted in the desired output.

Also, if an empty string can occur put the do until loop in a Condition checking for the string equal to '', otherwise it will fail.

 

TimVW_0-1657637406068.png

 

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,338)