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
Nate BakerNate Baker 

Exclude null values from average

I'm using the below formula field to attempt to average numeric responses, but exclude null values from the average. The formula is still counting the null value in the division. Any ideas?

Wrong average: 5+5+4+NULL = 14/4 = 3.5
Right average: 5+5+4+NULL = 14/3 = 4.67



(IF(ISNULL(CS1_Q1_answer__c),0,CS1_Q1_answer__c)+
IF(ISNULL(CS1_Q2_answer__c),0,CS1_Q2_answer__c)+
IF(ISNULL(CS1_Q3_answer__c),0,CS1_Q3_answer__c)+
IF(ISNULL(CS1_Q4_answer__c),0,CS1_Q4_answer__c))

/

(IF(ISNULL(CS1_Q1_answer__c),0,1)+
IF(ISNULL(CS1_Q2_answer__c),0,1)+
IF(ISNULL(CS1_Q3_answer__c),0,1)+
IF(ISNULL(CS1_Q4_answer__c),0,1))