Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to calculate the average of 3 months, 6 months, YTD?

Hi,

I have a requirement to calculate the average of users in 3 months, 6 months, YTD.

How do I write this logic for YTD and hardcode it?

I would really appreciate your help!

Thanks!

1 Reply
Anil_Babu_Samineni

Perhaps this? And you can ignore selection using strike though enabled.

num(((count({<USER_MONTH ={"$(=MONTH(Date(addmonths(Max(CREATEDDATE),-2), 'MMM')))"}, DateField = {">= $(=YearStart(Max(DateField))) <=$(=Max(DateField))"}, Year=, Week=, Quarter=>} distinct USER)
+
count({<USER_MONTH ={"$(=MONTH(Date(addmonths(Max(CREATEDDATE),-1), 'MMM')))"}, DateField = {">= $(=YearStart(Max(DateField))) <=$(=Max(DateField))"}, Year=, Week=, Quarter=>} distinct USER)
+
count({<USER_MONTH ={"$(=MONTH(Date(addmonths(Max(CREATEDDATE),0), 'MMM')))"}, DateField = {">= $(=YearStart(Max(DateField))) <=$(=Max(DateField))"}, Year=, Week=, Quarter=>} distinct USER))/3)
/
count({<CREATEDDATE ={"=$(=Date(Max(CREATEDDATE), 'MM-DD-YYYY'))"}, DateField = {">= $(=YearStart(Max(DateField))) <=$(=Max(DateField))"}, Year=, Week=, Quarter=>}distinct
USER)*100,'#,##0.0')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful