Forum Discussion

rhcentennialh's avatar
rhcentennialh
Helper II
7 years ago

Hierarchical Formula Calculation

I need to develop a formula that returns the sum of values based on a hierarchical structure. My calculation will look at a list of codes, each code has a value attributed to it. In addition, some codes are linked to each other through a secondary hierarchical structure. Meaning that if two codes are listed that are linked, the value for the top hierarchical code is to be used and not the second.

 

Please see an example of the hierarchy structure:

Value of CodeCode listSecondary Hierarch 
589,10,11,12
4910,11,12
31011,12
21112
112 
54648
248 

 

To help further I have three examples and what the solution should be for each.

 

Example 1: Codes 8,10,46,48 are listed. The calculated value should =  10

Example 2: Codes 10,11,12 are listed, the calculated value should = 3

Example 3: Codes 12,48 are listed, the calculated value should = 3

 

8 Replies

  • Just to be more clear on the examples and how the secondary hierarchy should work.

     

    Example 1: Codes 8,10,46,48 are listed. The calculated value should =  10 (Codes: 8+46)

    Example 2: Codes 10,11,12 are listed, the calculated value should = 3 (Codes: 10)

    Example 3: Codes 12,48 are listed, the calculated value should = 3 (Codes: 12+48)

     

     

    • v-cherch-msft's avatar
      v-cherch-msft
      Microsoft Employee

      Hi rhcentennialh 

      You may try below measures.Attached sample file for your reference.

      min_list = MINX(FILTER(ALLSELECTED(Code),Code[Hierarchy]=MAX(Code[Hierarchy])),Code[Code list])
      Codes = IF(ISBLANK(SUM(Code[Secondary Hierarch .1])),SUM(Code[Value of Code]),CALCULATE(SUM(Code[Value of Code]),FILTER(Code,Code[Code list]=[min_list])))

      Regards,

      • rhcentennialh's avatar
        rhcentennialh
        Helper II

        Thank you, however I need the formula to be more dynamic.

         

        I will have a list of thousands of individuals each with a unique set of codes. I would like the formula to auto calculate the sum rather than having to select the codes individually in the selection box you provided.