Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
Jerry Yang 8

# Formula field to calculate a score based on a customers age

Dear SF Dev Community. I am trying to create a formula field for a custom object. The objective of the formula is to calculate a score based on the value given by another field in the same custom object.

The value given by the field called Age__c. This field output an age value based on the customer’s birthday, and based on this age value, we want to calculate a score.

Example:
If (Age__c   >=  18 &&  Age__c  <=24), if this is true, then the output score is 20, else
If (Age__c   >=  25 &&  Age__c  <=32) if this is true, then the output score is 30, else

Could anyone please give me some guidance on how to write this sort of if/else if statement? Thanks!

Raj Vakati
Use this one

```If (Age__c   >=  18 &&  Age__c  <=24,24 ,
If (Age__c   >=  25 &&  Age__c  <=32 ,32,''))```

Jerry Yang 11
Thanks Raj. I am getting some syntax error with the following expression. It is either telling me found "ISBLANK" formula or it gives the error of ")"

If (Age__c  >=  18  &&  Age__c  <=24,20,
If (Age__c  >=  25  &&  Age__c  <=32 ,30,
If (Age__c  >=  33  &&  Age__c  <=39 ,25,
If (Age__c  >=  40  &&  Age__c  <=44 ,20,
If (Age__c  >=  45  &&  Age__c  <=54 ,15,
If (ISBLANK Age__C, Null,’’)
Raj Vakati
```If (Age__c  >=  18  &&  Age__c  <=24,
20,
If (Age__c  >=  25  &&  Age__c  <=32 ,30,
If (Age__c  >=  33  &&  Age__c  <=39 ,25,
If (Age__c  >=  40  &&  Age__c  <=44 ,20,
If (Age__c  >=  45  &&  Age__c  <=54 ,15,
If (ISBLANK Age__C, Null,’’)
))))))```

Jerry Yang 11
Hi Raj:

I am still getting the error Error: Incorrect parameter type for function 'IF()'.  Expected Number, received Text

If (Age__c  >=  18  &&  Age__c  <=24 ,20,
If (Age__c  >=  25  &&  Age__c  <=32 ,30,
If (Age__c  >=  33  &&  Age__c  <=39 ,25,
If (Age__c  >=  40  &&  Age__c  <=44 ,20,
If (Age__c  >=  45  &&  Age__c  <=54 ,15,
If ( ISBLANK( Age__c ), NULL, '')
)))))

Raj Vakati
```If (Age__c  >=  18  &&  Age__c  <=24,
20,
If (Age__c  >=  25  &&  Age__c  <=32 ,30,
If (Age__c  >=  33  &&  Age__c  <=39 ,25,
If (Age__c  >=  40  &&  Age__c  <=44 ,20,
If (Age__c  >=  45  &&  Age__c  <=54 ,15,
If (ISBLANK Age__C, Null,0)
))))))```

Raj Vakati
Is its working ?
Jerry Yang 11
Yes, It is working well! I have just tested it! Thanks for your great suppor!
Raj Vakati
Mark it as solved by choosing it as best answer !
Jerry Yang 11
I am new to this forum. I am not able to find where i am able to mark this question as solved and flag one of the answer as the "Best".

Raj Vakati
Click on thumbs up icon .. ref this
https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005ggjQAA
Jerry Yang 11
I am still having trouble finding this function. The flag button does not provide an option for best answer either.

Raj Vakati
https://developer.salesforce.com/forums/?id=9060G000000MVrtQAG