Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
afguillard
Contributor III
Contributor III

Rapatrier des informations dans une table

Bonjour,

J'avance pas à pas par rapport à ma question précédente mais j'ai à nouveau besoin de votre aide :

J'ai une table Commandes _Packs qui contient des champs suivants :

CommandePackIndicatifPackCodepromoPack
111111AAAAPACK_REUSS
222222BBBBPACK_AVANT
333333CCCCPACK_REUSS

Ma table 'Inscriptions' avec une multitude de champs dont un CodePromo pour certains indicatifs

AAAA
GGGG50
EEEE58
BBBB

Je veux rapatrier dans la seconde table les informations du champ CodePromoPack dans le champ CodePromo pour les Indicatifs présents dans la première table et conserver les CodePromo déjà présents.

IndicatifCodePromo
AAAAPACK_REUSS
GGGG50
EEEE58
BBBBPACK_AVANT

J'ai essayé différents join mais je n'ai pas réussi.

Merci

Anne

5 Replies
maxgro
MVP
MVP

RESULT

1.png

SCRIPT

a:

load * inline [

CommandePack, IndicatifPack, CodepromoPack

111111, AAAA, PACK_REUSS

222222, BBBB, PACK_AVANT

333333, CCCC, PACK_REUSS

];

b:

load * inline [

Indicatif, CodePromo

AAAA,

GGGG, 50

EEEE, 58

BBBB,

];

map:

mapping load IndicatifPack, CodepromoPack resident a;

final:

NoConcatenate

load

Indicatif, ApplyMap('map', Indicatif, CodePromo) as CodePromo

Resident b;

drop table b;

alexandros17
Partner - Champion III
Partner - Champion III

TAB1:

LOAD * Inline [

CommandePack, IndicatifPack, CodepromoPack

111111, AAAA, PACK_REUSS

222222, BBBB, PACK_AVANT

333333, CCCC, PACK_REUSS

];

TAB2:

LOAD * Inline [

Indicatif, CodePromo

AAAA,

GGGG, 50

EEEE, 58

BBBB,

];

MYTABTMP:

NoConcatenate

LOAD Indicatif, CodePromo Resident TAB2;

left join

LOAD IndicatifPack as Indicatif, CodepromoPack as tmpFld Resident TAB1;

DROP Tables TAB1, TAB2;

afguillard
Contributor III
Contributor III
Author

Bonjour,

J'ai essayé avec votre code mais ça ne fonctionne pas : les libellés "PACK" ne sont pas rapatriés dans le champ Code_statistique. Je vous met ci-dessous la totalité du code :

CommandesPacks:

LOAD distinct

Commande as CommandePack,

`Code Produit` as CodeProduitPack

resident Ecommerce

WHERE WildMatch(`Code Produit`, '*PACK*');

IndicatifPacks:

LOAD

Commande as CommandePack,

AnnéeSiteIndicatif as IndicatifsPacks

resident Ecommerce

WHERE Exists([CommandePack],[Commande]);

Outer join (CommandesPacks)

LOAD

CommandePack,

IndicatifsPacks

resident IndicatifPacks;

MYTABTMP:

NoConcatenate

LOAD

AnnéeSiteIndicatif,

Code_statistique

Resident Inscriptions;

left join

LOAD IndicatifsPacks as AnnéeSiteIndicatif,

CodeProduitPack as tmpFld

Resident CommandesPacks;

DROP Tables CommandesPacks, TAB2;

DROP Table WSBEL;

DROP Table IndicatifPacks;

Merci

Anne

afguillard
Contributor III
Contributor III
Author

Bonjour,

Ça fonctionne presque avec votre solution...sauf que maintenant chaque indicatif a deux codes promos alors que je veux que le premier code soit remplacé par le deuxième.

Voici le script tel que je l'ai rédigé :

ListeCommandesPacks:

LOAD distinct

Commande as Commande_Pack,

`Code Produit` as Code_Produit_Pack

resident Ecommerce

WHERE WildMatch(`Code Produit`, '*PACK*');

ListeIndicatifsPacks:

LOAD

Commande as Commande_Pack,

AnnéeSiteIndicatif as Indicatif_Pack

resident Ecommerce

WHERE Exists([Commande_Pack],[Commande]);

Outer join (ListeCommandesPacks)

LOAD

Commande_Pack,

Indicatif_Pack

resident ListeIndicatifsPacks;

Tmp_Inscriptions:

LOAD

AnnéeSiteIndicatif,

Code_statistique

Resident Inscriptions;

map:

mapping load Indicatif_Pack, Code_Produit_Pack resident ListeCommandesPacks;

Final:

NoConcatenate

load

AnnéeSiteIndicatif, ApplyMap('map', AnnéeSiteIndicatif,Code_statistique) as Code_statistique

Resident Tmp_Inscriptions;

DROP table Tmp_Inscriptions;

DROP Table WSBEL;

DROP Table ListeIndicatifsPacks;

DROP Tables ListeCommandesPacks;

almamy_diaby
Creator
Creator

Commandes _Packs:

mapping load

IndicatifPacks as Indicatif ,

CodepromoPacks

from 'Commandes _Packs';



Inscriptions:

load

Indicatif,

Applymap( 'Commandes _Packs', Indicatif, Codepromo) as Codepromo

from 'Inscriptions table';