cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jgriebel
Advocate I
Advocate I

int() function not working as expected

Hi, 

 

I having trouble using the int() function in MS Flow.

 

I have a simple input 

 

 

Annotation 2019-12-03 175750.png

and the following formulas:  

int(triggerBody()['text'])
int(triggerBody()['number'])
 
the first is working by just ignoring the , in the string.
But the 2nd is failing even if the input is an number with decimals.
 
I expected as result just the integer value of that number : 45563
 
what do I miss?
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
ScottShearer
Super User
Super User

@jgriebel 

See my example below.  You may/may not need to add a step that converts my output to an int using int().  The expressions that I used can be seen in the action comments.  Note that I am not rounding - just stripping out the period and anything that follows.

Split1.jpgSplit2.jpg

 

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

Scott

View solution in original post

3 REPLIES 3
Jay-Encodian
Community Champion
Community Champion

Hi @jgriebel 

You can't convert a decimal directly to an int... you can convert it to a float using the following expression: float(variable)

I couldn't see a simple expression for rounding the decimal... but this expression works: int(split(variable,'.')[0])

HTH

Jay

-------------------------------------------------------------------------

If I have answered your question, please mark your post as Solved.

If you like my response, please give it a Thumbs Up.

ScottShearer
Super User
Super User

@jgriebel 

See my example below.  You may/may not need to add a step that converts my output to an int using int().  The expressions that I used can be seen in the action comments.  Note that I am not rounding - just stripping out the period and anything that follows.

Split1.jpgSplit2.jpg

 

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

Scott
v-alzhan-msft
Community Support
Community Support

Hi @jgriebel ,

 

Please take a try with @ScottShearer  and @Jay-Encodian  's solution, it is works and could solve your problem.

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (4,598)