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
SapamrmSapamrm 

Sum of non-empty fields

Is it possible to make the sum of all the non-empty lookup fields (contact 1, 2 & 3) and automatically show this value in another field (# persons)

 

 

Thanks in advance!

 

 

Pradeep_NavatarPradeep_Navatar

You can use formula fields to achieve this. Formula fields enable customers to define their own business specific calculations and metrics inside Salesforce. With custom formula fields you can define numeric, text, and date calculations which are tailored to specific business needs.

 

For more help go to-> http://wiki.developerforce.com/index.php/An_Introduction_to_Formulas

SapamrmSapamrm

Ok got this one. Posted my question too soon.

SargeSarge

Hi,

 

   I guess you need to count the number of contacts if entered. So you need to have a formula field instead of text/ number fields.

 

Lets Say you have 3 contact lookups

1) Contact_1__c

2) Contact_2__c

3) Contact_3__c

 

the formula field  "x#_Persons__c" (Number 1,0) will show you the count of non-empty contacts, then the formula would be

 

(IF(LEN(Contact_1__c) > 0, 1, 0)) +

(IF(LEN(Contact_1__c) > 0,1,0))+

(IF(LEN(Contact_1__c) > 0,1,0))

 

Hope this example helps

SapamrmSapamrm

Thx Sarge.

 

In the meanwhile I found it myself and used the formula below. The result is same I guess.

 

 

(IF(ISBLANK( Contact_1__c ), 0, 1)) +

(IF(ISBLANK( Contact_2__c ), 0, 1)) +

(IF(ISBLANK( Contact_3__c ), 0, 1))