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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.