Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
KKumar92
Contributor III
Contributor III

Split Column into multiple Columns Dynamically Based on Condition

Hi All,

I have a BOM File as follow,

Semi-Finished|Finished_Good_NoSemi-Finished|Finished_Good_TypeRaw-Material_NoRaw-Material_TypeCumulative_Qtyunit_of_measure
FG001200100Finished GoodRM001500100Raw Material0.001kg
FG001200100Finished GoodRM001500101Raw Material0.45kg
FG001200100Finished GoodRM001500102Raw Material0.05kg
FG001200100Finished GoodRM001500103Raw Material0.65kg
FG001200100Finished GoodRM001500104Raw Material1kg
FG001200100Finished GoodSF008600100Semi-Finished Good1unit
FG001200100Finished GoodSF008600101Semi-Finished Good1unit
SF008600100Semi-Finished GoodRM001500100Raw Material0.7kg
SF008600100Semi-Finished GoodRM001500101Raw Material0.65kg
SF008600100Semi-Finished GoodRM001500109Raw Material0.4kg
SF008600100Semi-Finished GoodRM001500110Raw Material1.25kg
SF008600100Semi-Finished GoodSF008600121Semi-Finished Good1unit
SF008600101Semi-Finished GoodRM001500100Raw Material0.25kg
SF008600101Semi-Finished GoodRM001500101Raw Material0.003kg
SF008600101Semi-Finished GoodRM001500102Raw Material0.55kg
SF008600101Semi-Finished GoodRM001500107Raw Material0.8kg
SF008600121Semi-Finished GoodRM001500106Raw Material0.001kg
SF008600121Semi-Finished GoodRM001500117Raw Material0.076kg
SF008600121Semi-Finished GoodRM001500118Raw Material0.009kg
SF008600121Semi-Finished GoodRM001500119Raw Material0.089kg

In the above table it specifies the Raw Material and Semi-Finished Goods Required to manufacture either Finished Goods or Semi-Finished Goods.

My requirement is to breakdown the above table to multiple level according the production, and drill down till the last level as follow;

Finished_GoodLevel1_RM_RequiredCumulative_Qtyunit_of_measureLevel2_RM-RequiredCumulative_Qtyunit_of_measureLevel3_RM-RequiredCumulative_Qtyunit_of_measure
FG001200100RM0015001000.001kgN/R  N/R  
 RM0015001010.45kgN/R  N/R  
 RM0015001020.05kgN/R  N/R  
 RM0015001030.65kgN/R  N/R  
 RM0015001041kgN/R  N/R  
 SF0086001001unitRM0015001000.7kgN/R  
    RM0015001010.65kgN/R  
    RM0015001090.4kgN/R  
    RM0015001101.25kgN/R  
    SF0086001211unitRM0015001060.001kg
       RM0015001170.076kg
       RM0015001180.009kg
       RM0015001190.089kg
 SF0086001011unitRM0015001000.25kgN/R  
    RM0015001010.003kgN/R  
    RM0015001020.55kgN/R  
    RM0015001070.8kgN/R  

In the above table, I have drill down till only 3 levels, however this could be changed according to the product.

Please advise how this could be achieved on qlik sense.  Please find the attached image before for a better understanding.

KKumar92_0-1613021186775.png

 

2 Solutions

Accepted Solutions
morgankejerhag
Partner - Creator III
Partner - Creator III

This is potentially a quite advanced problem. Would it work for you to join and rename the fields a number of times? Like

Load
  [Semi-Finished|Finished_Good_No] as Finished_Good,
  Raw-Material_No as MaterialNo1,
  Cumulative_Qty as Cumulative_Qty1
from BOM.qvd (qvd) where [Semi-Finished|Finished_Good_Type]='Finished Good';

left join
Load
  [Semi-Finished|Finished_Good_No] as MaterialNo1,
  Raw-Material_No as MaterialNo2,
  Cumulative_Qty as Cumulative_Qty2
from BOM.qvd (qvd);

left join
Load
  [Semi-Finished|Finished_Good_No] as MaterialNo2
  Raw-Material_No as MaterialNo3,
  Cumulative_Qty as Cumulative_Qty3
from BOM.qvd (qvd);

And so on...

Morgan Kejerhag
Senior Business Intelligence Consultant
Drake Analytics
http://www.drakeanalytics.se

View solution in original post

Saravanan_Desingh

Try like this,

tab1:
Hierarchy([Raw-Material_No],[Semi-Finished|Finished_Good_No],Name,,[Semi-Finished|Finished_Good_No],'Path','/',Depth)
LOAD *, [Raw-Material_No] As Name;
LOAD * INLINE [
    Semi-Finished|Finished_Good_No, Semi-Finished|Finished_Good_Type, Raw-Material_No, Raw-Material_Type, Cumulative_Qty, unit_of_measure
    FG001200100, Finished Good, RM001500100, Raw Material, 0.001, kg
    FG001200100, Finished Good, RM001500101, Raw Material, 0.45, kg
    FG001200100, Finished Good, RM001500102, Raw Material, 0.05, kg
    FG001200100, Finished Good, RM001500103, Raw Material, 0.65, kg
    FG001200100, Finished Good, RM001500104, Raw Material, 1, kg
    FG001200100, Finished Good, SF008600100, Semi-Finished Good, 1, unit
    FG001200100, Finished Good, SF008600101, Semi-Finished Good, 1, unit
    SF008600100, Semi-Finished Good, RM001500100, Raw Material, 0.7, kg
    SF008600100, Semi-Finished Good, RM001500101, Raw Material, 0.65, kg
    SF008600100, Semi-Finished Good, RM001500109, Raw Material, 0.4, kg
    SF008600100, Semi-Finished Good, RM001500110, Raw Material, 1.25, kg
    SF008600100, Semi-Finished Good, SF008600121, Semi-Finished Good, 1, unit
    SF008600101, Semi-Finished Good, RM001500100, Raw Material, 0.25, kg
    SF008600101, Semi-Finished Good, RM001500101, Raw Material, 0.003, kg
    SF008600101, Semi-Finished Good, RM001500102, Raw Material, 0.55, kg
    SF008600101, Semi-Finished Good, RM001500107, Raw Material, 0.8, kg
    SF008600121, Semi-Finished Good, RM001500106, Raw Material, 0.001, kg
    SF008600121, Semi-Finished Good, RM001500117, Raw Material, 0.076, kg
    SF008600121, Semi-Finished Good, RM001500118, Raw Material, 0.009, kg
    SF008600121, Semi-Finished Good, RM001500119, Raw Material, 0.089, kg
];

View solution in original post

5 Replies
morgankejerhag
Partner - Creator III
Partner - Creator III

This is potentially a quite advanced problem. Would it work for you to join and rename the fields a number of times? Like

Load
  [Semi-Finished|Finished_Good_No] as Finished_Good,
  Raw-Material_No as MaterialNo1,
  Cumulative_Qty as Cumulative_Qty1
from BOM.qvd (qvd) where [Semi-Finished|Finished_Good_Type]='Finished Good';

left join
Load
  [Semi-Finished|Finished_Good_No] as MaterialNo1,
  Raw-Material_No as MaterialNo2,
  Cumulative_Qty as Cumulative_Qty2
from BOM.qvd (qvd);

left join
Load
  [Semi-Finished|Finished_Good_No] as MaterialNo2
  Raw-Material_No as MaterialNo3,
  Cumulative_Qty as Cumulative_Qty3
from BOM.qvd (qvd);

And so on...

Morgan Kejerhag
Senior Business Intelligence Consultant
Drake Analytics
http://www.drakeanalytics.se

Saravanan_Desingh

Try like this,

tab1:
Hierarchy([Raw-Material_No],[Semi-Finished|Finished_Good_No],Name,,[Semi-Finished|Finished_Good_No],'Path','/',Depth)
LOAD *, [Raw-Material_No] As Name;
LOAD * INLINE [
    Semi-Finished|Finished_Good_No, Semi-Finished|Finished_Good_Type, Raw-Material_No, Raw-Material_Type, Cumulative_Qty, unit_of_measure
    FG001200100, Finished Good, RM001500100, Raw Material, 0.001, kg
    FG001200100, Finished Good, RM001500101, Raw Material, 0.45, kg
    FG001200100, Finished Good, RM001500102, Raw Material, 0.05, kg
    FG001200100, Finished Good, RM001500103, Raw Material, 0.65, kg
    FG001200100, Finished Good, RM001500104, Raw Material, 1, kg
    FG001200100, Finished Good, SF008600100, Semi-Finished Good, 1, unit
    FG001200100, Finished Good, SF008600101, Semi-Finished Good, 1, unit
    SF008600100, Semi-Finished Good, RM001500100, Raw Material, 0.7, kg
    SF008600100, Semi-Finished Good, RM001500101, Raw Material, 0.65, kg
    SF008600100, Semi-Finished Good, RM001500109, Raw Material, 0.4, kg
    SF008600100, Semi-Finished Good, RM001500110, Raw Material, 1.25, kg
    SF008600100, Semi-Finished Good, SF008600121, Semi-Finished Good, 1, unit
    SF008600101, Semi-Finished Good, RM001500100, Raw Material, 0.25, kg
    SF008600101, Semi-Finished Good, RM001500101, Raw Material, 0.003, kg
    SF008600101, Semi-Finished Good, RM001500102, Raw Material, 0.55, kg
    SF008600101, Semi-Finished Good, RM001500107, Raw Material, 0.8, kg
    SF008600121, Semi-Finished Good, RM001500106, Raw Material, 0.001, kg
    SF008600121, Semi-Finished Good, RM001500117, Raw Material, 0.076, kg
    SF008600121, Semi-Finished Good, RM001500118, Raw Material, 0.009, kg
    SF008600121, Semi-Finished Good, RM001500119, Raw Material, 0.089, kg
];
Saravanan_Desingh

Output:

commQV93.PNG

KKumar92
Contributor III
Contributor III
Author

Hi Morgan,

Thanks for the solution provided, and it works for the requirement I have given above. As you have mentioned, the number of levels could vary according to the product for example;

Product A can have 3-level breakdown, while the Product B has 5-level breakdown. Is there any possibilities to make this script dynamic than making it static?

I am working on it, and appreciate you inputs as well.

Thanks,

Kishore

KKumar92
Contributor III
Contributor III
Author

Hi Saran,

Thanks for the solution given above, this works fine perfectly for both static and dynamic datasets.

Thanks,

Kishore