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 III
Super User III

@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
Super User II
Super User II

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 III
Super User III

@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

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
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (100,328)