Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello qlikers,
I'm encoutring the following issue:
I need to create a link between two tables
* ventesDCOM: order lignes where each line has and order id, product id, date and estimated delivery: timerange
* Livraison: contains a simulation of delivery made by clients on web site but i don't have any order id; but I have a multivalue field with product ids composing the shopping basket (product id concatenated and comma separated)
I need to link each basket to the order id if it has the same componements.
please find data simple in attachement.
I have tried to load ventesDCOM grouped by order id and concatenate the product ids to reconstruct the basket, but this is not possible because i'm not having always the right order to identify correctly the fields.
please also find app in attachement.
Can you please help?
Thank you very much.
Regards,
here the script i finaly used:
Let vAffiniteMint =00; //definir l'affinite de filtrage en minutes
Let vAffiniteSec =10; //definir l'affinite de filtrage en secondes
ventesDCOM:
LOAD
ORDERITEMS_ID,
ORDERS_ID,
PARTNUM, // = CODIC
// STATUS, // Statut de la
// LASTCREATE, // Date de création de la commande
Timestamp(date#(LASTCREATE,'DD/MM/YYYY hh:mm')) as timestamp_lastcreate, //conversion en timestamp
Timestamp(date#(LASTCREATE,'DD/MM/YYYY hh:mm')-MakeTime(00,$(vAffiniteMint),$(vAffiniteSec))) as timestamp_lastcreate_start,//interval min - tolérance 10 secondes
Timestamp(date#(LASTCREATE,'DD/MM/YYYY hh:mm')+MakeTime(00,$(vAffiniteMint),$(vAffiniteSec))) as timestamp_lastcreate_end, //interval max - tolérance 10 secondes
// NUMCMD, // Numero de commande dans les systèmes legacy (provenant de Mainframe)
TIMERANGE, //créneau de livraison proposé JO =Jounée / MA = Matin / AM / SO / S1 / S2/ S3
// DELIVERYDATE,
// TIMERANGE, // Colonne présente 2 fois dans le fichier souce
SHIPPINGDATE //Date de livraison
// DATE_TOPE, //Date de livraion effectuée
// SHIPPING_START_HOUR, // heure de début du créneau de livraison
// SHIPPING_END_HOUR //heure de fin du créneau de livraison
FROM
ventesDCOM*.csv
(txt, codepage is 1252, embedded labels, delimiter is ';', msq);
// CALCUL DU NB d'ARTICLES PAR COMMANDE
inner join
LOAD ORDERS_ID,
count(PARTNUM) as Nb_Articles_DCOM
RESIDENT ventesDCOM
GROUP BY ORDERS_ID;
//RECONSTITUTION D'UNE LIGNE PANIER
inner join
LOAD ORDERS_ID,
text(Concat(PARTNUM,',')) as panier_DCOM
Resident ventesDCOM
GROUP BY ORDERS_ID;
//SUPPRESSION DU CODE ARTICLE UNIRAIE (PARTNUM et ORDERITEMS_ID)
DROP Fields PARTNUM, ORDERITEMS_ID;
///$tab Livraison
// on charge la table livraison - on crée une clé unique du codic pour la reconstruction
Livraison:
LOAD
AutoNumber(codic&date&heure&insee) as key_codic, // clé necessaire pour reconstruire le panier
// date,
// heure,
Timestamp(date&' '&heure,'DD/MM/YYYY hh:mm:ss') as timestamp_livraison,
// marque,
// canal,
codic,
SubField(codic,',') as codic_split,
insee,
dateLivraison,
delaiLivraison
// setUpService
FROM
Livraison*.csv
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);
//concaténation des codic pour reprendre le bon ordre en utilisant la clé déjà crée
inner join
LOAD key_codic,
text(Concat(codic_split,',')) as panier_DCOM // Panier_Livraison = panier_DCOM 1er point de jointure
resident Livraison
Group by key_codic;
Drop Fields codic_split,codic,key_codic;
//EXIT SCRIPT;
///$tab RAPPROCHEMENT
Inner Join //avec table livraison
IntervalMatch (timestamp_livraison, panier_DCOM) //interval match etendu sur deux clés
Load //load des champs clés pour jointure avec table livraison
timestamp_lastcreate_start, //borne inferieure interval: clé sec1
timestamp_lastcreate_end, //borne supérieure interval: clé sec2
panier_DCOM //clé principale
Resident ventesDCOM; //fin interval match
LEFT JOIN //on reconstruit la table ventes à partir de la table précédante
LOAD * RESIDENT ventesDCOM;
DROP TABLE ventesDCOM; //ensuite on drop table vente d'origine
///$tab exit
EXIT SCRIPT;