Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to create one table

Hi All,

I have the following 2 tables:

Actual Table:

YearMonth, Category ,ActualRevenue

2013-1-1, A, 200

2013-2-1,A,300

2013-3-1,A,500

Focast table:

YearMonth, Category, FocastRevene

2013-4-1,A,0

Based onthe above 2 tables, I want to focast the revenue for the second table, the logic is Take the average of the last 3 months and the Category is the same.

So for YearMonth=2013-4-1, the Focast revenue (200+300+500)/3

How to use scrip to do it?

Thanks.

Labels (1)
2 Replies
michael_maeuser
Partner Ambassador
Partner Ambassador

load

MonthsStart(1, Today(), 0) as YearMonth

avg(if(month(yearmonth)>= month(today())-3, actualrevenue) as ActualRevenue

resident ActualTable ;

michael_maeuser
Partner Ambassador
Partner Ambassador

sum instead of avg of course and in the if expression add year(yearmonth)=year(today())