Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Bonjour à tous,
Mon problème est le suivant :
J'a une table "SGT" à 2 champs nommée "Depart" & "ArrivéeJ'aimerai à partir des lignes de champs existants créer un nouveau champ qui vérifie la condition suivante:
Pour N = nombre de ligne de la table, si la première valeur du champ "Arrivée" = Seconde valeur du champ "Depart" Alors ,
créer un champ "escale" qui prend cette valeur, sinon passer à la valeur suivante:
Exemple:
Depart | Arrivee |
---|---|
CDG | MAD |
MAD | VEN |
VEN | NYK |
NYK | CDG |
on a le champ "escale" comme suit
Escale |
---|
MAD |
VEN |
NYK |
J'ai fait ceci comme code:
for a=0 to Recno()
Table:
LOAD
If(Peek([Arrivée],$(a))=Peek([Depart],$(a)+1),Peek([Off point],$(a)),' ') as Escale,
Resident SGT;
next ;
Je vous remercie beaucoup
HI,
Try like this,
Test:
LOAD *,if(departure = Previous(Arrival), departure) as Stop Inline
[
departure,Arrival
CDG,MAD
MAD,VEN
VEN,NYK
NYK,CDG
];
Hope it helps
Thanks so much!
I have another question; How can i do to start comparison at the second row of "Departure" field?
Best regards V
Hi,
You can use peek function. like this
peek(fieldname [ , row [ , tablename ] ] )
Returns the contents of the fieldname in the record specified by row in the internal table tablename. Data are fetched from the associative QlikView database.
Fieldname must be given as a string (e.g. a quoted literal).
Row must be an integer. 0 denotes the first record, 1 the second and so on. Negative numbers indicate order from the end of the table. -1 denotes the last record read.
If no row is stated, -1 is assumed.
Examples:
peek( 'Sales' )
returns the value of Sales in the previous record read ( equivalent to previous(Sales) ).
peek( 'Sales', 2 )
returns the value of Sales from the third record read from the current internal table.
peek( 'Sales', -2 )
returns the value of Sales from the second last record read into the current internal table.
peek( 'Sales', 0, 'Tab1' )
returns the value of Sales from the first record read into the input table labeled Tab1.
If you achieve your requirement, mark as correct or helpful answer, that another can know the answer too.
Hope it helps