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

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

Re: int() function not working as expected

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

Re: int() function not working as expected

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.

Super User
Super User

Re: int() function not working as expected

@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

Community Support Team
Community Support Team

Re: int() function not working as expected

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
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!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,426)