Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Qlik Sense - Order by in load script

Hi experts!

Is it possible to order a table in the LOAD SCRIPT by a specific field in Qlik Sense?

I have to do that in the load script, because i want to add another filed with sequential numbers there.

Thank you!

12 Replies
OmarBenSalem

Try this:

LIB CONNECT TO 'XXX';

load *, rowNo() as RowNo;

LOAD*

    order by IDconcat

    ;

LOAD id,

    oKey,

    pId as PID,

    RDate,

   RDate&': '&oKey&id&pId as IDconcat,

        ;

SQL SELECT id,

    oKey,

    pId,

    RDate

FROM "XXX_xxx".dbo."XXXABC"

WHERE YEAR(RDATE)>YEAR(GETDATE())-3

ArnadoSandoval
Specialist II
Specialist II

Hi Andrea,

Sorry for getting involved with Omar proposed solution, but if you are getting the data from a database, like Oracle, MS Sql Server, or other vendor supporting Views, you could create the query at the database as a view with the required sorting, it could be more efficient if the back-end database does the job instead of Qlik.

Be aware your idea could back-fire, because Record-X could get a different rowNo() everyday (if re-creating the QVD every day, or the same rowNo() assigned to multiple records if you implemented an incremental QVD creation)

HTH

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.
shubham_singh
Partner - Creator II
Partner - Creator II

How about this

LOAD id,

    oKey,

    pId as PID,

    RDate,

    RDate&': '&oKey&id&pId as IDconcat,

    RowNo() as RowNum

    ;

SQL SELECT id,

    oKey,

    pId,

    RDate

FROM "XXX_xxx".dbo."XXXABC"

WHERE YEAR(RDATE)>YEAR(GETDATE())-3

ORDER BY id,oKey,pId,RDate;