Skip to main content

Hi Folks,

I am working on a workflow that calculates a new employee's available leave based on the employee's start date. If the start date was January 1st, they would get 15 days of leave. The leave value must be rendered in increments of .5 (1/2) days. So, if a person, based on their start date calculates to 3.8 days, I want it to round up to 4 days of available leave. If they have 6.1, I want t to round up to 6.5 days of available leave. The leave date should never round down in my use case.

Has anyone here ran across this problem before? Any ideas on a strategy to accomplish it?

Thanks and Regards,

Patrick Kelligan

From this site:Create an Inline Function to Round Up or Down to a Nearest Multiple – Customer Feedback for Nintex

"With the help of the Nintex support team, I discovered that there is no OOTB way to round a number to a nearest multiple."


But I did find this related to rounding in Nintex Forms - OnPrem.

Rounding Numbers with Nintex Forms


Thanks Dean Virag! I think that the strategy might be figuring out how, via workflow actions, to evaluate the decimal place and substitute it. Scratching my head on that now. I will let you know if I figure it out.

Patrick


Not using forms yet. Looking to add them to the arsenal soon though.


Hi Patrick

I have had a little play and done the following:

  1. Used a regular expression to extract the decimal part of the number (i.e the 4 of 12.4)
  2. Used a set a condition action to check if the number above is greater than 5
  3. if it is not, I have used this build string action to replace the decimal fn-Replace(fn-Replace(fn-Replace(fn-Replace({ItemProperty:Original_x0020_Number}, ".1", ".5"), ".2", ".5"), ".3", ".5"), ".4", ".5")
  4. if it is, I have used math operation to add 1 to the number, and then used this replace function fn-Replace(fn-Replace(fn-Replace(fn-Replace({WorkflowVariable:vTextOriginalPlus1}, ".6", ".0"), ".7", ".0"), ".8", ".0"), ".9", ".0")

it has made the following replacements for me:

1.0 = 1.0

1.1 = 1.5

1.2 = 1.5

1.3 = 1.5

1.4 = 1.5

1.5 = 1.5

1.6 = 2.0

1.7 = 2.0

1.8 = 2.0

1.9 = 2.0


Hi Cassy Freeman,

I came up with a very similar solution that I am debugging now. Since you did the leg work on this and it is a working solution, I will give you the correct answer on it. Thanks so much for the response and confirmation!

Best Regards,

Patrick


Hi @cassymfreeman,


 


Would you mind explaining how you went around using regular expression to extract the decimal part of the number? I've not used it before and am finding it a little confusing.


 


I'm trying to do something similair but always have the number round up.


 


Thanks


Reply