Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem with Products Quantities on a Hierarchy Structure

Hello, i'm having a problem to calculate the quantities of products that are in a hierarchy structure. There are several levels of subproducts, and its not a balanced tree, so the last levels are not always the same.  I have used the Hierarchy function to achieve this structure, here is the code:

Product:

Hierarchy ( ID_SubProduct,ID_Product, Level,,Level, Treeview,,Depth)

LOAD

    Quantity_MP,

    Quantity,

    ID_Product,

    ID_SubProduct,

    ID_SubProduct as Level

Resident STA03_TEMP;

The structure looks like this:

Level 1Level 2the Level 3Level 4Level 5Level 6Quantity
Quantity MP
Product AMP4-----5
Product ASubProduct 2MP3----2
Product ASubProduct 2----2-
Product ASubProduct 1SubProduct 4

MP 2

---10
Product ASubProduct 1SubProduct 4MP 1---2
Product ASubProduct 1SubProduct 4---1-
Product ASubProduct 1----2-
Product A-------

What i need to do is to multiply the Quantity of the every subproduct level with the Quantities MP of the last levels.  For example, the MP2 quantity should be:

  • (Subproduct 1 Quantity) * (SubProduct 4 Quantity) * (MP2 Quantity MP)
  • 2 * 1 * 10

The MP1 Quantity should be:

  • (Subproduct 1 Quantity) * (SubProduct 4 Quantity) * (MP1 Quantity MP)
  • 2 * 1 * 2

The MP4 Quantity should be:

  • (MP4 Quantity MP)
  • 5

Once i have the correct results of the Quantities of the MP Products, i need to store the new value on the Quantity MP field so i can use that values later on. My intention is to generate those values in the script then.

If anyone can help me with this ill be truly grateful.

Thank you.

PS: Sorry for my english, if there is a part that is not very understandable feel free to tell me so i can try to explain me better.

2 Replies
Not applicable
Author

Any ideas?

Not applicable
Author

Hey man, i ve the same problem.... Its very dificult.