Calculating in a ragged hierarchy?

Options

Does anyone know how to do a calculation in a ragged hierarchy which returns to the level of the hierarchy?

Best Answer

  • ChrisMullen
    Answer ✓
    Options
    Hi Emily,

    In my example, I am working from a flat version of my ragged hierarchy with a property that contains the parent.
    I created a module with just that flat list and some line items.

    The first set of line items "walk out" the hierarchy.  What I mean by this is it uses the PARENT and LOOKUP functions to build out all the parents above each item.
    Example formula  to putll the items second level parent -   Flat List.'Parent (item)'[LOOKUP: 'Parent 1 (item)']

    After you have built out enjoy Parent Lookup line items that your maximum number of levels is set, you can calculate the level of an item.
    In the images below, the max number of levels was 7. 

    In order to calculate the Level, just use an IF..Than  statement with  ISNOTBLANK to count backwards from the max level.
    IF ISNOTBLANK('Parent 7 (item)') THEN 7 ELSE IF ISNOTBLANK('Parent 6 (item)') THEN 6 ELSE IF ISNOTBLANK('Parent 5 (item)') THEN 5 ELSE IF ISNOTBLANK('Parent 4 (item)') THEN 4 ELSE IF ISNOTBLANK('Parent 3 (item)') THEN 3 ELSE IF ISNOTBLANK('Parent 2 (item)') THEN 2 ELSE IF ISNOTBLANK('Parent 1 (item)') THEN 1 ELSE 0

    -Chris

Answers

  • Monpero
    Options

    Hi @ChrisMullen,

    I've got a question please, from my understanding in building this.

    The flat list needs to be a numbered list with the code and 3 properties; Display name, Parent name, Parent ID.

    If the flat list is called Flat List Import.

    What List will hold the items of the Parent? is the Parent line item format a list or text.

    If it is a text one can't do a lookup on text.

    Do we have separate list for the child and parent?

    Please your response will be very helpful as I'm struggling to understand this initial part.