Discussions
Categories
 17.9K All Categories
 3.4K Industry Applications
 3.4K Intelligent Advisor
 73 Insurance
 537.3K OnPremises Infrastructure
 138.6K Analytics Software
 38.6K Application Development Software
 6K Cloud Platform
 109.6K Database Software
 17.6K Enterprise Manager
 8.8K Hardware
 71.2K Infrastructure Software
 105.3K Integration
 41.6K Security Software
Round up (Round.top) function in OIA
In my OIAmodel, I want the outcome of a certain rulebase to always round up to the nearest whole number instead of rounding down. For example 5.23, 5.44, 5.87 al have to become 6. And 150.2 and 150.9 have to become 151.
I can only find the function Round(), but it automatically rounds up or down depending which one is closest. Does anyone have a solution for this?
Thank you in advance.
Best Answers

Hi
You could use a combination of Trunc() and a comparison.
If your number X is 3.3, you create an attribute Y to store the Trunc(X, 0) version which gives us 3.
Then you substract X from Y. Anything more than a 0 as a result means you need to round up, so add one to the truncated value. You could also use Remainder to divide X by Y and if you get a remainder other than 0 you round up by 1.
Store that in your new attribute. There are probably a gazillion more elegant ways to do it, but that seems to fit your scenario. I may be wrong if I have misinterpreted it or am missing a piece.
Hope that helps. Trunc is documented here : https://documentation.custhelp.com/euf/assets/devdocs/unversioned/IntelligentAdvisor/en/Content/Guides/Policy_Modeling_User_Guide/Work_with_rules/Write_rules_using_calculations/Perform_mathematical_calculations_in_rules.htm?Highlight=Trunc
R

Richard was faster than me, I was going to propose something similar (in french version, sorry) :

You could also do this with a formula instead of a rule where your result is originally calculated (assuming you don't want both the actual and rounded value.
Round ((Trunc(X * 1000, 0) + 500 ) / 1000)
You can vary the "1000" and "500" to select the number of significant digits that cause "uprounding" (i.e. to the third digit after the decimal in this case)
If it isn't critical to control the significant digits you consider you can simplify to Round (X + .49999... ) to get a very similar results)
In either case test the boundary conditions to get the exact results you want (i.e. .999.....9999, 1, 1..00000....00001 , 1.50000001 , etc to ensure you get the number of significant digits you require).

When I've needed to round up, it's typically been in the context of rounding up currency values. Here's an approach I've used for the following requirement...
Example source material
If the input amount is not already in whole dollars, round it up to the next whole dollar. For example:
 If the input amount is $5, the result is $5.
 If the input amount is $5.01, the result is $6.
Example rule
 the result = Trunc((the input amount + 0.99), 0)
Cheers,
Jasmine
Answers

Hi
You could use a combination of Trunc() and a comparison.
If your number X is 3.3, you create an attribute Y to store the Trunc(X, 0) version which gives us 3.
Then you substract X from Y. Anything more than a 0 as a result means you need to round up, so add one to the truncated value. You could also use Remainder to divide X by Y and if you get a remainder other than 0 you round up by 1.
Store that in your new attribute. There are probably a gazillion more elegant ways to do it, but that seems to fit your scenario. I may be wrong if I have misinterpreted it or am missing a piece.
Hope that helps. Trunc is documented here : https://documentation.custhelp.com/euf/assets/devdocs/unversioned/IntelligentAdvisor/en/Content/Guides/Policy_Modeling_User_Guide/Work_with_rules/Write_rules_using_calculations/Perform_mathematical_calculations_in_rules.htm?Highlight=Trunc
R

Richard was faster than me, I was going to propose something similar (in french version, sorry) :

You could also do this with a formula instead of a rule where your result is originally calculated (assuming you don't want both the actual and rounded value.
Round ((Trunc(X * 1000, 0) + 500 ) / 1000)
You can vary the "1000" and "500" to select the number of significant digits that cause "uprounding" (i.e. to the third digit after the decimal in this case)
If it isn't critical to control the significant digits you consider you can simplify to Round (X + .49999... ) to get a very similar results)
In either case test the boundary conditions to get the exact results you want (i.e. .999.....9999, 1, 1..00000....00001 , 1.50000001 , etc to ensure you get the number of significant digits you require).

When I've needed to round up, it's typically been in the context of rounding up currency values. Here's an approach I've used for the following requirement...
Example source material
If the input amount is not already in whole dollars, round it up to the next whole dollar. For example:
 If the input amount is $5, the result is $5.
 If the input amount is $5.01, the result is $6.
Example rule
 the result = Trunc((the input amount + 0.99), 0)
Cheers,
Jasmine