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: 
Not applicable

script issue

hello,

I am facing some issue in scripting can any one correct me.

Syntax error, missing/misplaced FROM:

     If(SNO_WEEK=1,'FW' & Right(FISCAL_YEAR_WEEK_NUM,2)),

       If(SNO_WEEK >= 1 and SNO_WEEK <= 4,'FW' & Right(Max(FISCAL_YEAR_WEEK_NUM),2) &'-' &'FW' & Right(Min(FISCAL_YEAR_WEEK_NUM),2),

       If(SNO_WEEK >= 1 and SNO_WEEK <= 13,'FW' & Right(Max(FISCAL_YEAR_WEEK_NUM),2) &'-' &'FW' & Right(Min(FISCAL_YEAR_WEEK_NUM),2),

       If(SNO_WEEK >= 1 and SNO_WEEK <= 52,'FW' & Right(Max(FISCAL_YEAR_WEEK_NUM),2) &'-' &'FW' & Right(Min(FISCAL_YEAR_WEEK_NUM),2),

       ))))

       AS TIMELINE,

 

Thanks

14 Replies
simenkg
Specialist
Specialist

You are using an aggregate function(min and max) without a group by statement.

Add AFTER the FROM statement.:

Group by SNO_WEEK;

Or another field if that is not the right one to group by.

Not applicable
Author

I have tried all your solutions but still I was facing issue,any more possible solutions.

Thanks

Not applicable
Author

My first thought will be that I hope you are using GROUP BY clause with this. Since you are calculating Max and Min or fields in the IF condition. Try keeping Hard coded values in IF condition and then check.

And also, if you could calculate Max and Min of fields before in variable or other table. And then use it to join with your calendar, might help you.

Thanks,

Angad

simenkg
Specialist
Specialist

Then you should try to remove the min and max. Here is how you do it:

First create a temporary table.

MinMax:

Load

     min(FISCAL_YEAR_WEEK_NUM) as MinWeekNum,

     max(FISCAL_YEAR_WEEK_NUM) as MaxWeekNum

from

....


Let vMinWeekNum = peek('MinWeekNum',0,'MinMax');

Let vMaxWeekNum = peek('MaxWeekNum',0,'MinMax');


drop table MinMax;


//Then you load your original table with the if.  

     If(SNO_WEEK=1,'FW' & Right(FISCAL_YEAR_WEEK_NUM,2),

       If(SNO_WEEK >= 1 and SNO_WEEK <= 4,'FW' & Right('$(vMaxWeekNum)',2) &'-' &'FW' & Right('$(vMinWeekNum)',2),

       If(SNO_WEEK >= 1 and SNO_WEEK <= 13,'FW' & Right('$(vMaxWeekNum)',2) &'-' &'FW' & Right('$(vMinWeekNum)',2),

       If(SNO_WEEK >= 1 and SNO_WEEK <= 52,'FW' & Right('$(vMaxWeekNum)',2) &'-' &'FW' & Right('$(vMinWeekNum)',2),

       ))))

       AS TIMELINE,

Regards

SKG

Not applicable
Author

Thanku simen looks you are close to my requirement but I need to find min and max numbers based on SNO_WEEK numbers.Your script will give min and max for all data.

see the below link for expected output

http://community.qlik.com/message/582415#582415

Thanks