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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
rulloa
Regular Visitor

sum and average

Hello everyone, the question is:

I have the following table.

CustomerSub CustomerMonthAmount
AAX1100000031
AAX295000028
AAX390250031
AAX485737530
AAX581450631
AAX677378130
AAX773509231
AAX869833731
AAX966342030
AAX1063024931
AAX11100003
AAY195000031
AAY290250028
AAY385737531
AAY481450630
AAY577378131
AAY673509230
AAY769833731
AAY866342031
AAY963024930
AAY1059873731
AAY115688008
BBX185000031
BBX280750028
BBX376712531
BBX472876930
BBX569233031
BBX665771430
BBX762482831
BBX859358731
BBX956390730
BBX1053571231
BBX1150892615
BBY170000031
BBY266500028
BBY363175031
BBY460016330
BBY557015431
BBY654164730
BBY751456431
BBY848883631
BBY946439430
BBY1044117531
BBY11 12

 

I need to calculate in Power BI the amount for each subcustomer which is the sum of the amount (easy) but when grouping by customer should be the average of the amount of the subcustomers in every customer. And before the customer i have more levels. And these leves must be calculated in the same way that the customers like this.

 

CustomerSub CustomerMonthTotal Amount
AAX 307
 AY 312
Total A avg309,5
BBX 319
 BY 316
Total B avg317,5
Total generalavg313,5

 

Could you help me to do it?

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Anonymous
Not applicable

Hi @rulloa,

Create the following measures in your table and create a Matrix visual as shown in below screenshot.


SumAmountbycustomer = CALCULATE(SUM('Table'[Amount]),ALLEXCEPT('Table','Table'[Customer]))
countofsubcustomer = CALCULATE(DISTINCTCOUNT('Table'[Sub Customer]),ALLEXCEPT('Table','Table'[Customer]))
Average = [SumAmountbycustomer]/[countofsubcustomer]

1.PNG


Thanks,
Lydia Zhang

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @rulloa,

Create the following measures in your table and create a Matrix visual as shown in below screenshot.


SumAmountbycustomer = CALCULATE(SUM('Table'[Amount]),ALLEXCEPT('Table','Table'[Customer]))
countofsubcustomer = CALCULATE(DISTINCTCOUNT('Table'[Sub Customer]),ALLEXCEPT('Table','Table'[Customer]))
Average = [SumAmountbycustomer]/[countofsubcustomer]

1.PNG


Thanks,
Lydia Zhang

Greg_Deckler
Community Champion
Community Champion

https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.