how can I sum the fields contain null values
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
Solved! Go to Solution.
- Labels:
- Trifacta Classic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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)
