Alteryx Designer Cloud Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Cloud.
SOLVED

how can I sum the fields contain null values

WuCong
8 - Asteroid

as you can see ,I want to sum some fields, and the fields may have null values. we want to sum the non-null values.

what function should I use?

2 REPLIES 2
AMiller_Tri
Alteryx Alumni (Retired)

Hi @wu cong? , thank you for your question!

 

when using the SUM() function, it sums the non-null values:

So you don't need to use a particular function for this scenario.

 

Now, if you want to sum the row instead of the column - you can first nest the columns to an array, using the 'nest columns into object' transform:

and then use the LISTSUM() function to sum the values in the array:

You can see that although there are null values in the array - the function knows to sum only the numbers

 

I hope that makes sense; please feel free to ask any additional questions.

 

Thanks,

Amit.

The sum value will be NULL . If you want to do additions in the database: use SUM if it's an option to sum up a column of a result set instead of expressions ( SUM ignores NULL values) wrap columns with https://bit.ly/3u0MQHK COALESCE(column, 0) ( COALESCE takes the first non-null argument)

Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!