Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
souadouert
Contributor III

sorting data

i Used this script to sort client for each agency and load only the 20 first

agence:

LOAD distinct

  agenc

   

FROM

(qvd);



for vRow = 1 to NoOfRows('agence')

Let MyVar = Peek('agenc',vRow-1,'agence');

first 20

HGFINAL:

load *

FROM

(qvd)


Where AGENCE = '$(MyVar)'

order by PNB ;

 


Next

But nothing changed

1 Solution

Accepted Solutions

Re: sorting data

You can use the Order By clause only on resident loads. So you first need to load the data in a temporary table. Then you can do a resident load from that temporary table and use the Order By to sort it.

agence:

LOAD distinct

     %ID_AGENCE_CTOS_CLIENT

FROM

    

     (qvd)

     ;

Temp:

LOAD

    *

FROM

   

    (qvd)

WHERE

     Exists(%ID_AGENCE_CTOS_CLIENT )

    ;


DROP TABLE agence;


Result:

LOAD

     *

WHERE

     Counter <= 20;

LOAD

     *,

    AutoNumber(RecNo(), %ID_AGENCE_CTOS_CLIENT) as Counter

RESIDENT

     Temp

ORDER BY

      %ID_AGENCE_CTOS_CLIENT,

     PNB

     ;


DROP TABLE Temp;

DROP Field Counter;


talk is cheap, supply exceeds demand
2 Replies

Re: sorting data

You can use the Order By clause only on resident loads. So you first need to load the data in a temporary table. Then you can do a resident load from that temporary table and use the Order By to sort it.

agence:

LOAD distinct

     %ID_AGENCE_CTOS_CLIENT

FROM

    

     (qvd)

     ;

Temp:

LOAD

    *

FROM

   

    (qvd)

WHERE

     Exists(%ID_AGENCE_CTOS_CLIENT )

    ;


DROP TABLE agence;


Result:

LOAD

     *

WHERE

     Counter <= 20;

LOAD

     *,

    AutoNumber(RecNo(), %ID_AGENCE_CTOS_CLIENT) as Counter

RESIDENT

     Temp

ORDER BY

      %ID_AGENCE_CTOS_CLIENT,

     PNB

     ;


DROP TABLE Temp;

DROP Field Counter;


talk is cheap, supply exceeds demand
souadouert
Contributor III

Re: sorting data

thank you thank but just you need to put desc with order by

Community Browser