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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

aggr

I have a doubt,

I have an average daily consumption, which depends on my variable 'v_month'

if the variable is 3 for example:

consumption is related to last month + the last two months earlier ...
(Last month = 8, consumption refers to the months 6,7,8) shared by a time period.

expression:

/ / 1st part (following the example that the variable value is 3 and the last month is the month in August, this part of the expression demonstrates the intake covering the months June, if not have consumption in month June, the consumption value will be 0)



if (aggr (if (year_drug = max (total <ds_drug> year_drug) if (month_num = max ({<year_drug {'> = = 2006 '}>} total <ds_drug> month_num) - (v_month - 1), sum (= {<year_drug {'> = 2006 '}>} consumption))), ds_drug, month_num, year_drug)
, Aggr (if (year_drug = max (total <ds_drug> year_drug) if (month_num = max ({<year_drug {'> = = 2006 '}>} total <ds_drug> month_num) - (v_month - 1), sum ( = {<year_drug {'> = 2006 '}>} consumption))), ds_drug, month_num, year_drug)
, 0)

+

/ / 2nd part (following the same example, this part of the expression should show the consumption for the months longer than the six, if doesn't exist greater months the value will be 0)

if (
aggr (if (year_drug = max (total <ds_drug> year_drug) if (month_num> max ({<year_drug {'> = = 2006 '}>} total <ds_drug> month_num) - (v_month - 1), sum ({ <year_drug {'> = = 2006 '}>} consumption))), ds_drug, month_num, year_drug)
, Aggr (if (year_drug = max (total <ds_drug> year_drug) if (month_num> max ({<year_drug {'> = = 2006 '}>} total <ds_drug> month_num) - (v_month - 1), sum ( = {<year_drug {'> = 2006 '}>} consumption))), ds_drug, month_num, year_drug)
, 2000)

/



/ / 3rd party (it's a period of time between the last date - the variable of months)

if (aggr (if (year_drug = max (total <ds_drug> year_drug) if (month_num = max ({<year_drug {'> = = 2006 '}>} total <ds_drug> month_num) - (v_month - 1), sum (= {<year_drug {'> = 2006 '}>} consumption))), ds_drug, month_num, year_drug)
, Aggr (if (year_drug = max (total <ds_drug> year_drug) if (month_num = max ({<year_drug {'> = = 2006 '}>} total <ds_drug> month_num) - (v_month - 1), sum ( = {<year_drug {'> = 2006 '}>} consumption))), ds_drug, month_num, year_drug)
, 0)

if the variable is 1 or 2, the expression works .... if the variable is greater than 3, does not work ...

(The problem is in the 2nd part ... if it is to consider the term more than one month, it does not work)

Also I have to increase the expression, a way that, if consumption is for the months 6,7,8.
and 7 months, for example, there is no consumption, adding only the consumption of the other months, which have (6.8)

I sending an example to help you to understanding my problem...

http://community.qlik.com/media/p/156732/download.aspx

0 Replies