Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
souadouert
Specialist
Specialist

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
Gysbert_Wassenaar

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

View solution in original post

2 Replies
Gysbert_Wassenaar

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
Specialist
Specialist
Author

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