Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Rollup Values for Child Records

Hello, 

 

Below is a sample table that I have and I'm trying to find a way to calculate the values for the last 2 columns. Because Location Code 1 is a parent of Location Code 2, and Location Code 2 is a parent of both Location Codes 3 and 4, the rollup value is 215,000 (50,000+150,000+10,000+5,000), and so on for the other Location Codes. What is the formula to achieve that? Any kind of help will be appreciated.

 

Location CodeParent Location CodeSumOfCostOf ReplacementTotal Asset CountReport CostOf ReplacementReport Total Asset Count
1NULL50,0000215,00029
21150,00020165,00029
3210,0005N/AN/A
425,0004N/AN/A
  • Hi Anonymous

    Create calculated columns

    parentmatch = CALCULATE(MAX([Parent Location Code]),FILTER(ALL(Sheet1),[Parent Location Code]=EARLIER(Sheet1[Location Code])))
    allid = IF([parentmatch]=BLANK(),[Parent Location Code],[parentmatch])
    parent = CALCULATE(MIN([parentmatch]),FILTER(ALL(Sheet1),[allid]=EARLIER(Sheet1[allid])-1))
    category = IF([Parent Location Code]=BLANK(),[parentmatch],[parent])
    Column 6 = IF([Parent Location Code]=BLANK(),CALCULATE(SUM(Sheet1[SumOfCostOf Replacement]),ALLEXCEPT(Sheet1,Sheet1[category])),IF([parentmatch]<>BLANK(),CALCULATE(SUM(Sheet1[SumOfCostOf Replacement]),ALLEXCEPT(Sheet1,Sheet1[allid]))))
    Column 7 = IF([Parent Location Code]=BLANK(),CALCULATE(SUM(Sheet1[Total Asset Count]),ALLEXCEPT(Sheet1,Sheet1[category])),IF([parentmatch]<>BLANK(),CALCULATE(SUM(Sheet1[Total Asset Count]),ALLEXCEPT(Sheet1,Sheet1[allid]))))

     

    Best Regards

    Maggie

2 Replies

  • v-juanli-msft's avatar
    v-juanli-msft
    Community Support

    Hi Anonymous

    Create calculated columns

    parentmatch = CALCULATE(MAX([Parent Location Code]),FILTER(ALL(Sheet1),[Parent Location Code]=EARLIER(Sheet1[Location Code])))
    allid = IF([parentmatch]=BLANK(),[Parent Location Code],[parentmatch])
    parent = CALCULATE(MIN([parentmatch]),FILTER(ALL(Sheet1),[allid]=EARLIER(Sheet1[allid])-1))
    category = IF([Parent Location Code]=BLANK(),[parentmatch],[parent])
    Column 6 = IF([Parent Location Code]=BLANK(),CALCULATE(SUM(Sheet1[SumOfCostOf Replacement]),ALLEXCEPT(Sheet1,Sheet1[category])),IF([parentmatch]<>BLANK(),CALCULATE(SUM(Sheet1[SumOfCostOf Replacement]),ALLEXCEPT(Sheet1,Sheet1[allid]))))
    Column 7 = IF([Parent Location Code]=BLANK(),CALCULATE(SUM(Sheet1[Total Asset Count]),ALLEXCEPT(Sheet1,Sheet1[category])),IF([parentmatch]<>BLANK(),CALCULATE(SUM(Sheet1[Total Asset Count]),ALLEXCEPT(Sheet1,Sheet1[allid]))))

     

    Best Regards

    Maggie

    • Anonymous's avatar
      Anonymous
      Not applicable

      That works like a charm!

       

      Thanks Maggie.