cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Axal
Level: Powered On

Error while convert string to number

Hi,

I have 2 variables: 1 is string and 1 is integer. The string value already get from a table and substring it with "Compose" step. By looking at the Output, it is with '0' prefix, so it's like '0002'.

 

Now I want to convert it to integer. Can this be done with SetVariable and put the expression ? or we still need to add another Compose action ? My current step is just SetVariable like below:

image.png

 

Btw, the expression is initially put as "int(outputs('Compose'))", but it looks Flow change it (is it ?) output('Compose') is my previous step name to get variable with string type.

 

The error currently is :

image.png

 

What parameter I should use then ?

 

Thanks in advance,

Axal

 

 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Axal
Level: Powered On

Re: Error while convert string to number

Hi Manuel,

 

I solved it with addition Compose step. Somehow it works with the "int(outputs())" as below:

image.png

 

Then after that I had another step for "Set variable" pointing to the output of the above step.

image.png

Appreciate your help. Thanks,

Axal

 

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Error while convert string to number

Hi @Axal 

 

All makes sense, but the issue is that the int function doesn't know how to convert "0002". You have to remove the trailing 0 first so that you're able to convert it. A simple replace(<variable>;"0";"") will do the trick.

 

Let me know how this works out for you.

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

Axal
Level: Powered On

Re: Error while convert string to number

Hi Manuel,

 

I solved it with addition Compose step. Somehow it works with the "int(outputs())" as below:

image.png

 

Then after that I had another step for "Set variable" pointing to the output of the above step.

image.png

Appreciate your help. Thanks,

Axal

 

View solution in original post

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (3,313)