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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

need help on resident code.

Hi, i am getting script error for below code:
BudgetTemp:
CROSSTABLE(State1,BUDGETREVENUE,4)
LOAD TYPE,
VENDOR,
'FY' &
right([FY YEAR],2) as [FY YEAR1],
[FY MONTH],
NSW,
VIC,
QLD,
SA,
WA,
ACT,
TAS,
NT,
NZ,
OTHER
FROM
avnet_budget_data.txt
(
txt, codepage is 1252, embedded labels, delimiter is '|', msq);

Budget:
LOAD rowno() as BudgetID,
[FY MONTH] as [Fiscal Month],
[FY YEAR1],
TYPE,
VENDOR,
State1,
SUM(if(TYPE = 'budget',BUDGETREVENUE)) as BUDGET,
SUM(if(TYPE = 'forecast',BUDGETREVENUE)) as FORECAST
RESIDENT BudgetTemp;
Could you please help me out with this syntax error?
1 Solution

Accepted Solutions
jagan
Partner - Champion III
Partner - Champion III

Hi,

I think you are getting error in second Load statement, because you are using an aggregation function(Sum) without using Group By.

Try this

Budget:
LOAD rowno() as BudgetID,
[FY MONTH] as [Fiscal Month],
[FY YEAR1],
TYPE,
VENDOR,
State1,
SUM(if(TYPE = 'budget',BUDGETREVENUE)) as BUDGET,
SUM(if(TYPE = 'forecast',BUDGETREVENUE)) as FORECAST
RESIDENT BudgetTemp

GROUP BY [FY MONTH][FY YEAR1],
TYPE,
VENDOR,
State1;

Hope this helps you.

Regards,

Jagan.

View solution in original post

2 Replies
jagan
Partner - Champion III
Partner - Champion III

Hi,

I think you are getting error in second Load statement, because you are using an aggregation function(Sum) without using Group By.

Try this

Budget:
LOAD rowno() as BudgetID,
[FY MONTH] as [Fiscal Month],
[FY YEAR1],
TYPE,
VENDOR,
State1,
SUM(if(TYPE = 'budget',BUDGETREVENUE)) as BUDGET,
SUM(if(TYPE = 'forecast',BUDGETREVENUE)) as FORECAST
RESIDENT BudgetTemp

GROUP BY [FY MONTH][FY YEAR1],
TYPE,
VENDOR,
State1;

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

Hi Jagan,yes, you are right.thanks for your help.