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

Announcements
Week 2: Presenting "Automate Sucess" and "Integration for Innovation" - WATCH NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Script loading invalid expression

Hi all,

I'm practising script. This one works:

Directory;

Maintable:

LOAD date(date#(SalesDate,'MM/DD/YYYY'),'DD-MM-YYYY') as SalesDate,

     SalesVolume

FROM

practicecalendar.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);


MasterCalendar:

Load

Date(SalesDate) as SalesDate,

Year(SalesDate) as Year,

'Q'&ceil(month(SalesDate)/3) as Quarter,

Day(SalesDate) as Day,

Week(SalesDate) as Week,

Month(SalesDate) as Month,

Resident Maintable;


But then I created two additional fields and get the error that the expression is invalid.

Min(SalesDate) as MinDate,

Max(SalesDate) as MaxDate


Directory;

Maintable:

LOAD date(date#(SalesDate,'MM/DD/YYYY'),'DD-MM-YYYY') as SalesDate,

     SalesVolume

FROM

practicecalendar.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);


MasterCalendar:

Load

Date(SalesDate) as SalesDate,

Year(SalesDate) as Year,

'Q'&ceil(month(SalesDate)/3) as Quarter,

Day(SalesDate) as Day,

Week(SalesDate) as Week,

Month(SalesDate) as Month,

Min(SalesDate) as MinDate,

Max(SalesDate) as MaxDate

Resident Maintable;

Can anyone please help explain the reason? And how to detect the cause so that next time I can get it right?

Thank you.

1 Solution

Accepted Solutions
Anil_Babu_Samineni

Try this way?

Maintable: 

LOAD date(date#(SalesDate,'MM/DD/YYYY'),'DD-MM-YYYY') as SalesDate, 

    SalesVolume 

FROM 

practicecalendar.csv 

(txt, codepage is 1252, embedded labels, delimiter is ',', msq); 

MasterCalendar: 

Load 

Date(SalesDate) as SalesDate, 

Year(SalesDate) as Year

'Q'&ceil(month(SalesDate)/3) as Quarter, 

Day(SalesDate) as Day

Week(SalesDate) as Week, 

Month(SalesDate) as Month

Resident Maintable;

 

Load Min(SalesDate) as MinDate, 

Max(SalesDate) as MaxDate 

Resident Maintable;


But, I really didn't understand why you need Min and Max Date if you are not using anywhere As of Now?

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

View solution in original post

3 Replies
Anil_Babu_Samineni

Try this way?

Maintable: 

LOAD date(date#(SalesDate,'MM/DD/YYYY'),'DD-MM-YYYY') as SalesDate, 

    SalesVolume 

FROM 

practicecalendar.csv 

(txt, codepage is 1252, embedded labels, delimiter is ',', msq); 

MasterCalendar: 

Load 

Date(SalesDate) as SalesDate, 

Year(SalesDate) as Year

'Q'&ceil(month(SalesDate)/3) as Quarter, 

Day(SalesDate) as Day

Week(SalesDate) as Week, 

Month(SalesDate) as Month

Resident Maintable;

 

Load Min(SalesDate) as MinDate, 

Max(SalesDate) as MaxDate 

Resident Maintable;


But, I really didn't understand why you need Min and Max Date if you are not using anywhere As of Now?

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
Anonymous
Not applicable
Author

Many thanks Anil. Being a novice, can I understand why do we need to separating it into 2 Loads with 2 resident Maintable? In my simple mind, Min/Max is just like other above functions.

Anil_Babu_Samineni

I am creating Min and Max dates from Maintable using SalesDate. Then, We can create separate table for Calendar to get associated with All fact fields into Dimension tables and Fields from calendar.

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