Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PhuongTN
Frequent Visitor

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
1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @PhuongTN

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]))))

7.png

 

Best Regards

Maggie

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @PhuongTN

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]))))

7.png

 

Best Regards

Maggie

That works like a charm!

 

Thanks Maggie.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.