Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Average() function: where is it documented? How to average two dates?

JohnDoe
8 - Asteroid

 

Entering a formula like Average([numerical_column_1],[numerical_column_2]) works. However, is the formula documented anywhere? I haven't been able to find any documentation, nor can I find it in the 'functions' tab of the formula tool.

 

Also, is there any way to get it to work with dates? If I try the formula with two date fields, I get:

 

Error: Formula (19): Parse Error at char(0): Type mismatch. String provided where a number is required. (Expression #1)

 

which is weird because the fields are dates, not strings!

 

Note that I am talking about averaging two columns (an average by row), NOT about doing any kind of group by.

 

Thanks.

2 REPLIES 2
jdunkerley79
ACE Emeritus
ACE Emeritus

Alteryx stores dates as strings. You would need to convert them to a days since an epoc and then average and finally add the epoc. Something like:

 

DateTimeAdd("1900-01-01", Average(
	DateTimeDiff([Field1],"1900-01-01","days"),
	DateTimeDiff([Field2],"1900-01-01","days")
), "days")

 

The average function is documented here:

http://help.alteryx.com/9.5/Reference/Functions.htm#Math_

AlexKo
Alteryx Alumni (Retired)

Another option is the Average Dates macro on the Gallery. This macro will average dates in a field with an optional grouping, so using it to average across two fields would require some data transformation.

 

For your purposes I think jdunkerley79's solution would work more elegantly.

Alex Koszycki
Program Manager, Community Platform
Labels