function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kabkab 

Is there any formula avaialable to use which will round a number?

I want to use the function to round it to next number. for example 2.1 should be 3 and 2.4 should be 3 also 2.7 should be 3

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard
Ah, didn't notice you wanted next higher number, not rounded value. Try the ceiling function instead.

All Answers

goabhigogoabhigo

Since ROUND() function rounds to nearest number (for eg: 2.1 to 2, 2.8 to 3) , why not try this??

 

IF( VALUE( RIGHT( TEXT(UrField__c),1 )) < 5 && LEN(TEXT(UrField__c)) > 1 ,

 ROUND((UrField__c + 0.5 )),

 ROUND(UrField__c,1))

goabhigogoabhigo

Hey found out better solution for this:

 

ROUND(YourNumber__c + 0.4)

 

Surprised? Confused?? Even I was. Just see the following table:

 

9     + 0.4 = 9.4 -> ROUND(9.4)= 10

9.1  + 0.4 = 9.5 -> ROUND(9.5)= 10

9.2  + 0.4 = 9.6 -> ROUND(9.6)= 10

.

.

9.8  + 0.4 = 10.2 -> ROUND(10.2)= 10

9.9  + 0.4 = 10.3 -> ROUND(10.3)= 10

10.1  + 0.4 = 10.5 -> ROUND(10.5)= 11

 

Not my solution though, but looks interesting and its easier than my previous solution.

aballardaballard
Ah, didn't notice you wanted next higher number, not rounded value. Try the ceiling function instead.
This was selected as the best answer
goabhigogoabhigo

Ohh man why this didn't come to my mind!!! Just wasted my time thinking of complex logics :(

 

Thanks aballard.

kabkab

Hi Abhi,

 

Thanks for your solution. your solution looks good but my question was "is there any  function available in SFDC which can be used directly.

 

again thanks for your response. I appriciate it.

aballardaballard

See my response above....

goabhigogoabhigo

Always welcome kab.