Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
GuillaumeB
Contributor II
Contributor II

Ajouter n colonnes à 1 table en fonction des informations des informations de cette même table

Bonjour,

J'ai une table contenant les informations de conditionnement des articles, c'est à dire le code, la quantité et que le code du sous conditionnement pour chaque conditionnement (cf. PJ). (Un article = 1, un carton = 10 articles, un colis = 20 articles, etc..)

Quand un conditionnement possède un code de sous-conditionnement  j'aimerais que le script ajoute :

_Une colonne avec la quantité du sous-conditionnement

_Une colonne avec la quantité du sous-sous-conditionnement

Et ainsi de suite jusqu'à qu'il n'y ai plus de sous conditionnement. (Cf. PJ)

Comment faire ?

 

Merci d'avance,

Guillaume

Guillaume Boquet
Log'S
1 Solution

Accepted Solutions
Taoufiq_Zarra

Bonjour @GuillaumeB ,

Je ne sais pas si tu as trouvé une solution, mais voilà une :

 

Input:

HierarchyBelongsTo(ID0, CC, [Code sous cond.],Ancestor_ID,Ancestor_Name,DepthDiff)

LOAD 
     [Code article]&'_'&[Code cond.] as ID0,
     [Code article], 
     [Code cond.], 
     [Qté cond.], 
     [Code sous cond.],
     [Code article]&'_'&[Code sous cond.] as CC
FROM
[.\Classeur1.xlsx]
(ooxml, embedded labels, table is Feuil2);


Temp1:
noconcatenate

load ID0,[Code article],[Code cond.],subfield(Ancestor_ID,'_',2) as TmpCodevalue,if(DepthDiff=0,'Code cond.','Code sous cond.'&DepthDiff) as Tmp_Code_s_cond

resident Input;


Temp2:
noconcatenate

load ID0,[Code article] ,[Code cond.] as C ,Ancestor_ID as Ccode,if(DepthDiff=0,'Qté cond.','Qté sous cond. '&DepthDiff) as Tmp_qte_s_cond

resident Input;
left join 
load distinct [Code article]&'_'&[Code cond.] as Ccode,[Qté cond.] as Cqte resident Input;
drop table Input;


CombinedGenericTable:

Load distinct [Code article]&'_'&[Code cond.] as ID resident Temp1;


DATA:
 Generic LOAD
 
 [Code article]&'_'&[Code cond.] as ID,Tmp_Code_s_cond,TmpCodevalue resident Temp1;
 
 drop table Temp1;
 
 FOR i = NoOfTables()-1 to 0 STEP -1

  LET vTable=TableName($(i));
  IF WildMatch('$(vTable)', 'DATA.*') THEN 

  LEFT JOIN ([CombinedGenericTable]) LOAD distinct * RESIDENT [$(vTable)];

  DROP TABLE [$(vTable)];

  ENDIF 

NEXT i



DATA2:
 Generic LOAD
 
 [Code article]&'_'&C as ID,Tmp_qte_s_cond,Cqte resident Temp2;
 
 drop table Temp2;
 
 FOR i = NoOfTables()-1 to 0 STEP -1

  LET vTable=TableName($(i));
  IF WildMatch('$(vTable)', 'DATA2.*') THEN 

  LEFT JOIN ([CombinedGenericTable]) LOAD distinct * RESIDENT [$(vTable)];

  DROP TABLE [$(vTable)];

  ENDIF 

NEXT i


Final:
noconcatenate

load subfield(ID,'_',1) as [Code article],* resident CombinedGenericTable;

drop fields ID;

drop table CombinedGenericTable;

 

 

fichier source :

un fichier Excel (Classeur1.xlsx) avec les données :

Capture.PNG

 

Résultat :

Capture.PNG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

2 Replies
Taoufiq_Zarra

Bonjour @GuillaumeB ,

Je ne sais pas si tu as trouvé une solution, mais voilà une :

 

Input:

HierarchyBelongsTo(ID0, CC, [Code sous cond.],Ancestor_ID,Ancestor_Name,DepthDiff)

LOAD 
     [Code article]&'_'&[Code cond.] as ID0,
     [Code article], 
     [Code cond.], 
     [Qté cond.], 
     [Code sous cond.],
     [Code article]&'_'&[Code sous cond.] as CC
FROM
[.\Classeur1.xlsx]
(ooxml, embedded labels, table is Feuil2);


Temp1:
noconcatenate

load ID0,[Code article],[Code cond.],subfield(Ancestor_ID,'_',2) as TmpCodevalue,if(DepthDiff=0,'Code cond.','Code sous cond.'&DepthDiff) as Tmp_Code_s_cond

resident Input;


Temp2:
noconcatenate

load ID0,[Code article] ,[Code cond.] as C ,Ancestor_ID as Ccode,if(DepthDiff=0,'Qté cond.','Qté sous cond. '&DepthDiff) as Tmp_qte_s_cond

resident Input;
left join 
load distinct [Code article]&'_'&[Code cond.] as Ccode,[Qté cond.] as Cqte resident Input;
drop table Input;


CombinedGenericTable:

Load distinct [Code article]&'_'&[Code cond.] as ID resident Temp1;


DATA:
 Generic LOAD
 
 [Code article]&'_'&[Code cond.] as ID,Tmp_Code_s_cond,TmpCodevalue resident Temp1;
 
 drop table Temp1;
 
 FOR i = NoOfTables()-1 to 0 STEP -1

  LET vTable=TableName($(i));
  IF WildMatch('$(vTable)', 'DATA.*') THEN 

  LEFT JOIN ([CombinedGenericTable]) LOAD distinct * RESIDENT [$(vTable)];

  DROP TABLE [$(vTable)];

  ENDIF 

NEXT i



DATA2:
 Generic LOAD
 
 [Code article]&'_'&C as ID,Tmp_qte_s_cond,Cqte resident Temp2;
 
 drop table Temp2;
 
 FOR i = NoOfTables()-1 to 0 STEP -1

  LET vTable=TableName($(i));
  IF WildMatch('$(vTable)', 'DATA2.*') THEN 

  LEFT JOIN ([CombinedGenericTable]) LOAD distinct * RESIDENT [$(vTable)];

  DROP TABLE [$(vTable)];

  ENDIF 

NEXT i


Final:
noconcatenate

load subfield(ID,'_',1) as [Code article],* resident CombinedGenericTable;

drop fields ID;

drop table CombinedGenericTable;

 

 

fichier source :

un fichier Excel (Classeur1.xlsx) avec les données :

Capture.PNG

 

Résultat :

Capture.PNG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
GuillaumeB
Contributor II
Contributor II
Author

Merci Taoufiq

Guillaume Boquet
Log'S