I want to calculate the sum of past 12 months but not include the current month, and I tried to use windowsum function. However, in windowSum function,
the start index is a positive integer, indicating n rows above the current row, while the end index is a positive integer, indicating n rows below the current row.
E.g., windowSum(sum(monthly quantity),[month ASC],12,0) would cover the past 12 month and the current month, but what if i only want past 12 month, not include the current month. let’s say for month Oct 2024, i want the sum of value from Oct 2023 to Sep 2024. Is there a way to do it?
This would be to get the distinct Count if it’s this year.
avg(distinctCountOver(ifelse({last tweleve months}=addDateTime(-1,‘YYYY’,now()),{session_id},NULL),[{last tweleve months}],PRE_AGG))
I realize I could have just used
windowSum(sum(monthly quantity),[month ASC],12,0) - windowSum(sum(monthly quantity),[month ASC],0,0)
the last 12 months - the current month
Hi @yuchen1,
Since we haven’t heard back, I’ll close out this topic. However, if you have any additional questions, feel free to create a new post in the community and link this discussion for relevant information if needed.