Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
mato32188
Specialist
Specialist

Easier syntax solution ... ?

Hi there,

load works well, but I would like to know whether

exists any solution how to make this script syntax EASIER or not?:

StructureProd:

Hierarchy(UpPrOrderNum, PrOrderNum, ProdOrder) LOAD

     UpPrOrderNum ,

      PrOrderNum,

      PrOrderNum as ProdOrder

FROM

..\Table1.qvd

(qvd);

MAP_UPITEMCODE:

Mapping LOAD

     PrOrderNum as UpPrOrderNum,

     ItemCode

FROM

..\Table1.qvd

(qvd);

MAP_ITEMCODE1:

Mapping LOAD

     PrOrderNum as ProdOrder1,

     ItemCode

FROM

..\Table1.qvd

(qvd);

MAP_ITEMCODE2:

Mapping LOAD

     PrOrderNum as ProdOrder2,

     ItemCode

FROM

..\Table1.qvd

(qvd);

MAP_ITEMCODE3:

Mapping LOAD

     PrOrderNum as ProdOrder3,

     ItemCode

FROM

..\Table1.qvd

(qvd);

MAP_ITEMCODE4:

Mapping LOAD

     PrOrderNum as ProdOrder4,

     ItemCode

FROM

..\Table1.qvd

(qvd);

;

MAP_ITEMCODE5:

Mapping LOAD

     PrOrderNum as ProdOrder5,

     ItemCode

FROM

..\Table1.qvd

(qvd);

MAP_ITEMCODE6:

Mapping LOAD

     PrOrderNum as ProdOrder6,

     ItemCode

FROM

..\Table1.qvd

(qvd);

MAP_ITEMCODE7:

Mapping LOAD

     PrOrderNum as ProdOrder7,

     ItemCode

FROM

..\Table1.qvd

(qvd);

StructureItem:

LOAD *, ApplyMap('MAP_UPITEMCODE', UpPrOrderNum, null()) as UpItemCode,

        ApplyMap('MAP_ITEMCODE', PrOrderNum, null()) as ItemCode,

        ApplyMap('MAP_ITEMCODE1', ProdOrder1, null()) as ItemCode1,

        ApplyMap('MAP_ITEMCODE2', ProdOrder2, null()) as ItemCode2,

        ApplyMap('MAP_ITEMCODE3', ProdOrder3, null()) as ItemCode3,

        ApplyMap('MAP_ITEMCODE4', ProdOrder4, null()) as ItemCode4,

        ApplyMap('MAP_ITEMCODE5', ProdOrder5, null()) as ItemCode5,

        ApplyMap('MAP_ITEMCODE6', ProdOrder6, null()) as ItemCode6,

        ApplyMap('MAP_ITEMCODE7', ProdOrder7, null()) as ItemCode7

Resident StructureProd

;

DROP Table StructureProd

;   

ItemCode1 .. ItemCode7 maximum possible range generated by hierarchy function so far

Thank you in advance

M

ECG line chart is the most important visualization in your life.
1 Solution

Accepted Solutions
mato32188
Specialist
Specialist
Author

Hello Nicolas,

     hierarchy function creates fields named ProdOrder1 ... ProdOrder7 and I wanted to match those ProdOrders with ItemCodes from 1 to 7 to make the same hierarchy for Items. I am not sure, if such method is right, but it works.

ECG line chart is the most important visualization in your life.

View solution in original post

5 Replies
Not applicable

Hi Martin,

First of all, I might have missed something, but why use multiple Mapping Tables if you are loading the same fields from the same table ?

Regards,

Nicolas

mato32188
Specialist
Specialist
Author

Hello Nicolas,

     hierarchy function creates fields named ProdOrder1 ... ProdOrder7 and I wanted to match those ProdOrders with ItemCodes from 1 to 7 to make the same hierarchy for Items. I am not sure, if such method is right, but it works.

ECG line chart is the most important visualization in your life.
Not applicable

As far as I know, you don't need to have the exact same name for both fields when you use an ApplyMap.

The ApplyMap function compares the value with available values in the first column of the mapping table. Then, it returns the corresponding value in the second column.

Sadly, I have to recognize that I'm not a specialist in the use of the Hierarchy function, but - in my opinion - the use of only one mapping table is a first lead of improvement for this script.

sudeepkm
Specialist III
Specialist III

have you tried creating a hierarchy for ItemCodes using the similar script. then both tables may be associated based on the prod order num.

mato32188
Specialist
Specialist
Author

Thank you Nicolas for advice. You are right.

ECG line chart is the most important visualization in your life.