+ Start a Discussion
Prince VenkatPrince Venkat 

Formula Field for Object

Creating a formula field based on the age band based on the individual age from number 3 and above , Based on the table


AGe  Age Band
1     <20

2    <20

3     <20

4 <20

5 <20

6 <20

7 <20

8 <20

9 <20

10 <20

20 20-24

21 20-24

22 20-24

23 20-24

24 20-24

25 20-24

26 25-29

27 25-29

 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Venkat,

Do you want the Age Band based on the age?

Thanks,
Prince VenkatPrince Venkat
Yes
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Venkat,

The formula can be as below. Change the values as per your requirement.
 
IF( Age__c <20,'<20', IF(Age__c >=20 && Age__c<=24 ,'20-24','25-30') )

If this solution helps, Please mark it as best answer.

Thanks
Prince VenkatPrince Venkat
Hi Sai

Thanks for your contionous Support
I am trying to reflect it based on the Scenario Am I correct

IF( Age__c <20,'<20', IF(Age__c >=20 && Age__c<=24 ,'20-24', IF(Age__c >=25 && Age__c<=29 ,'25-29' , IF(Age__c >=30 && Age__c<=34 ,'30-34') ) ) )

 Error: Incorrect number of parameters for function 'IF()'. Expected 3, received 2

Getting Such Error . How do we close with ()
Prasanthi_s1505Prasanthi_s1505
Hello,
in the above IF condition  the last condition of IF has only 2 arguments passed
Please check after  '30-34' there should be false condition also here.
Suraj Tripathi 47Suraj Tripathi 47
Hi Prince Venkat,
IF( Age__c <20,'<20', IF(Age__c >=20 && Age__c<=24 ,'20-24', IF(Age__c >=25 && Age__c<=29 ,'25-29' , IF(Age__c >=30 && Age__c<=34 ,'30-34', true or false ) ) ) )
Make sure you have filled 3 value as parameter in formula field as expected
If you find your Solution then mark this as the best answer.
Thank you!
Regards,
Suraj Tripathi
 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Venkat,

You should give the else value for final if. i'e if the age is greater than 34 what should be the value.  Please update the formula as below
 
IF( Age__c <20,'<20', IF(Age__c >=20 && Age__c<=24 ,'20-24', IF(Age__c >=25 && Age__c<=29 ,'25-29' , IF(Age__c >=30 && Age__c<=34 ,'30-34','>34') ) ) )

Please refer the below article for more information on IF condition.

https://www.tech-vision.us/salesforce-the-easiest-way-to-write-if-formulas/

If this solution helps, Please mark it as best answer.

Thanks,
 
Prince VenkatPrince Venkat
Hi Suraj
IF(Age__c <20,'<20',
IF(Age__c >=20 && Age__c<=24,'20-24',
IF(Age__c >=25 && Age__c<=29,'25-29',
IF(Age__c >=30 && Age__c<=34,'30-34',
IF(Age__c >=35 && Age__c<=39,'35-39',
IF(Age__c >=40 && Age__c<=44,'40-44',
IF(Age__c >=45 && Age__c<=49,'45-49',
IF(Age__c >=50 && Age__c<=54,'50-54',
IF(Age__c >=55 && Age__c<=59,'55-59',
IF(Age__c >=60 && Age__c<=64,'60-64',
IF(Age__c >=65 && Age__c<=69,'65-69',
IF(Age__c >=70 && Age__c<=74,'70-74',
IF(Age__c >=75 && Age__c<=79,'75-79',
IF(Age__c >=80 && Age__c<=99,'80+',true or false)))))))))))))) still I am getting error


Sai  I Tried In this as well
IF(Age__c <20,'<20', IF(Age__c >=20 && Age__c<=24,'20-24', IF(Age__c >=25 && Age__c<=29,'25-29', IF(Age__c >=30 && Age__c<=34,'30-34', IF(Age__c >=35 && Age__c<=39,'35-39', IF(Age__c >=40 && Age__c<=44,'40-44', IF(Age__c >=45 && Age__c<=49,'45-49', IF(Age__c >=50 && Age__c<=54,'50-54', IF(Age__c >=55 && Age__c<=59,'55-59', IF(Age__c >=60 && Age__c<=64,'60-64', IF(Age__c >=65 && Age__c<=69,'65-69', IF(Age__c >=70 && Age__c<=74,'70-74', IF(Age__c >=75 && Age__c<=79,'75-79', IF(Age__c >=80 && Age__c<=99,'80+',''))))))))))))))

Getting Error


 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Venkat,

Are you getting the below error.

Compiled formula is too big to execute (9,895 characters)

This is because the formula size is very big so it is not able to compile. For these scenerioes please check the below article.

https://www.salesforcebolt.com/2020/10/5000-characters-limit-on-Formula-Field.html

Thanks,
Prince VenkatPrince Venkat
Hi Sai,

Then Cant we achieve this through Formula fields ?