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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

LOAD syntax question

I added the line starting with "FIRSTSORTEDVALUE" to my script.

LOAD



If(IsNull(Opp_StartDate),'1/1/1989',Year(Opp_StartDate)) As OppStYear,

MonthName(Opp_StartDate) As tStartMonth,

MonthName(Opp_ClosedDate) As tCloseMonth,

FirstSortedValue(Opp_StartDate,-Opp_StartDate) As NewestOpp Group by Company

* ;

OLEDB Connect to (connection string)

SELECT

(field list)

FROM (filename)

And this now generates a SQL error. "can't find field <*>"

I know my syntax is wrong, but I can't find anything in the documentation to fix it! Note that if I comment out the newly added line, everything runs perfectly, so I know the problem is there.

Any thoughts?

2 Replies
bgerchikov
Partner - Creator III
Partner - Creator III

Hi Kevin,

Group by clause must include actual field name. You have "*" right after "Company" with no comma.

Hope it will hellp.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Apart from the missing comma before the *, FirstSortedValue is an aggregate function and cannot be used the way you are attempting. The group by statement applies to the whole load, not just the line you entered. You could do something like this after completing the first load (let's give that table a label of Table1):

OLEDB Connect to (connection string);

 

Table1:

LOAD

          If(IsNull(Opp_StartDate),'1/1/1989',Year(Opp_StartDate)) As OppStYear,

          MonthName(Opp_StartDate) As tStartMonth,

          MonthName(Opp_ClosedDate) As tCloseMonth,

* ;

SQL SELECT

(field list)

FROM (sql table name);

 

Join (Table1)

LOAD Company,

     Max(OppStartDate) As NewestOpp

Resident Table1

Group By Company;

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein