Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
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
Sure, see the Round function:
http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_variables_functions.htm
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))
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.
Ohh man why this didn't come to my mind!!! Just wasted my time thinking of complex logics :(
Thanks aballard.
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.
See my response above....
Always welcome kab.
All Answers
Sure, see the Round function:
http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_variables_functions.htm
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))
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.
Ohh man why this didn't come to my mind!!! Just wasted my time thinking of complex logics :(
Thanks aballard.
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.
See my response above....
Always welcome kab.