Need Average function to ignore 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
The null field could be any of the 7.
Solved! Go to Solution.
- Labels:
- Preparation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
For me personally, since the Summarize Tool has no "average - ignore nulls", I update the nulls to zero before the Summarize Tool (then you can use the "average - ignore zeros") using either the Formula Tool or the Multi-Field Formula Tool (depending on how many fields I'm updating).
For the formula itself, if you use "ToNumber([FieldName])" just like that, and the field is numeric, then it will fill the nulls with zeros. Or, depending on my need, I may filter out the non-nulls and then use the Summarize Tool with just those non-nulls.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I could write a ton of nested If statements, but there are up to 13 fields needed in the calculation. I would need an If statement for every possible combination...there has to be an easier way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Use a multi-field formula to update all of your values with this expression:
i.e. set nulls to zero and increase every other value by 1.
- Then use the summarise tool with "average - ignore nulls" for all of your fields.
- Then use a second multi-field formula to update all of the newly created averages with this expression:
Which subtracts the one we added to all of the values in the first expression.
Adam
https://www.linkedin.com/in/adriley/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Apparently fall is the time to try to take averages inclusive of null values. AdamR's solution works for single fields, but if you want to take an average across multiple fields you need to first transpose the data, then summarize, then merge back in -- a pain. SPSS has a simple mean.x function that allows you to specify the maximum number of missing values that will allow it to return an average without error. Would love a similar functionality in Alteryx.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Maybe you can post this as an idea on the ideas board? Maybe with some guidance, you and I could create a macro for the community to benefit from. I'd be happy to work with you on it.
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.

