Windowavg date type issue

Hi Team, i’m trying to use Windowavg function, my formula is

windowAvg(count({title_count}),[{Date} ASC],-2,0)

, but I got an error says

Expression windowAvg(count({title_count}),[{Date} ASC],-2,0) for function windowAvg has incorrect argument type windowAvg(Number, <TIMESTAMP(0) ARRAY>, Number, Number). Function syntax expects Numeric, Non-empty List, Numeric, Numeric, List Numeric, Non-empty List, Numeric, Numeric. `

I assume it’s my date data type issue, the formula to get date is

parseDate(concat(toString(year),‘-’, toString(month),‘-’,‘01’),‘yyyy-MM-dd’)

how can i change the formula to make it work with windowavg function

Hello @Iris_Zhou - I believe this is related to the month field. The format that you specified in parseDate is looking for a month portion of 2 character, however if your month field is numeric then it is having a single character (for months 1 to 9), which may not satisfy. Can you please try the below expression instead? Let me know if this helps!

parsedate(
concat(
tostring({Order Year}), ‘-’, //This is the year Portion
right(concat(‘00’, tostring(OrderMonthNumeric)), 2), // This is the Month Portion; Since Month needs to be 2 digits, left padded with zero
‘-01’
), ‘yyyy-MM-dd’)

Did my suggestion help you in resolving your query? If yes, would request you to mark the post as “Solution”. This will help the community to find guidance and answers to similar question. Thank you!