Skip to main content
Nintex Community Menu Bar

Nintex Forms - math function

  • May 18, 2017
  • 12 replies
  • 83 views

Forum|alt.badge.img+7

Hi,

I have a case where I need to divide two numbers and round up to nearest integer and store the result in a calculated field. This is commonly known as a "ceiling" function.

ExampleDivisionRoundFloorCeiling
100 / 1010101010
18 / 101.8212
12 / 101.2112
3 / 100.3001

I can only seem to find a "round" function. Neither the "Floor" og the "Ceiling" is available as far as I can see.

Any ideas on how to overcome this?

Regards

Leif

12 replies

Forum|alt.badge.img+16

Hi

I have done the following before:

Take the value you have from division above and do the following:

1. calculate round

2. if round = division ---> set ceiling and floor = division

3. if round > division ---> set ceiling = round, floor = round - 1

4. if round < division ---> set ceiling = round + 1, floor = round

does that make sense?


Forum|alt.badge.img+16
  • May 18, 2017

You can use XSLT functions to calculate Floor and Ceiling

Take a look at this >>>  


Forum|alt.badge.img+14
  • Scholar
  • May 18, 2017

from calculated value control you can directly call javscript function, so something like this might help


Forum|alt.badge.img+11
  • Nintex Partner
  • May 18, 2017

Also, there's the % operator which gives you the remainder of a division. So 18%10 will return 8. Using the If() you could come up with the calculated value formulas that you're looking for.

For example the below seems to do the trick for me (using result examples from Wikipedia):

The subtraction part is to compensate for negative numbers.


Forum|alt.badge.img+7

Hi Cassy,

It definately makes sense - thanks for your input. I will have to wrap it in some nested "if/then" structure inside my formula however, since my problem relates to Forms instead of Workflow.

Regards

Leif


Forum|alt.badge.img+7

Hi Fernando,

I am not sure if this can somehow be utilized in a form. Is it not only within a workflow that this is working?

Regards

Leif


Forum|alt.badge.img+7

Hi Marian,

I hadn't thought of this. This is definately worth trying as long as Mobile Forms are not required - which it fortunately isn't in my case happy.png

Regards

Leif


Forum|alt.badge.img+7

Hi Jean-Pierre,

That's pretty awesome - simple but efficient. And it will work in Mobile Forms as well grin.png

Regards

Leif


Forum|alt.badge.img+16

Yeah sorry about that I went off on one without reading the title of the question properly! Glad you got a resolution! 


Forum|alt.badge.img+14
  • Scholar
  • May 19, 2017

I had doubts of whether this is going to work since '%' (resp. all the arithmetic operators) is as well javascript operator.

so I tested it on my own and found out it works. a bit of surprise for me.

so I tested Math.ceil()  and to my even bigger surprise it worked as well.

not sure how and why but it really works. at least on android.


Forum|alt.badge.img+13
  • Novice
  • July 10, 2017

This is awesome. Great that you can use javascript functions within a calculated value in a mobile app form as well as browser.


Forum|alt.badge.img+14
  • Scholar
  • July 10, 2017

Just not to confuse somebody, I do not say javascript works on mobile in general.

I just found single case where it worked happy.png