Flexmonster MCP Server is here! Connect your ✨AI assistant to our documentation. Get started
+

How to ignore nulls in average

Answered
antywong Antony Wong asked on September 13, 2017

Hi

Is there a way to ignore nulls when performing an average so those rows are not included in the aggregration?
 
I am returning Json data from an ajax call.  
 
Thanks
 

4 answers

Public
Ian Sadovy Ian Sadovy ⋅ Flexmonster ⋅ September 13, 2017

Hello Antony,
 
Thank you for the question.
Actually, it seems that null's are ignored when calculating the average (see http://jsfiddle.net/flexmonster/bmszjju9/).
Please let me know if you have any other questions.
 
Regards,
Ian

Public
antywong Antony Wong ⋅ September 13, 2017

Thanks for this.  However, if the first value is null, an aggregation cant be performed.  Is there a way round this?

Public
Ian Sadovy Ian Sadovy ⋅ Flexmonster ⋅ September 14, 2017

Hello Antony,
 
Yes, you can do this. Usually, first value used to determine the column type (i.e. string, number, date , etc.).
So, if the first value is null it will be determined by default as string. Therefore, you should set column type explicitly.
Please refer to the updated sample - http://jsfiddle.net/flexmonster/bmszjju9/
Also, here is more documentation about JSON data styles.
 
Hope it helps.
 
Regards,
Ian

Public
antywong Antony Wong ⋅ September 22, 2017

Thanks.  This worked

Please sign in or register to submit your answer