cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
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
Highlighted
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.

Highlighted
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

Highlighted
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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (7,772)