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
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (3,162)