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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

How do I first sum values then take average?

I have data that looks like this:

nameshours
diego

1

diego1
diego1
brittney4

 

I want to take the average hours per employee, but there are entries that have the same person's name repeated with small amounts of hours. In a perfect world, they would already all be added. So, to avoid having to edit the excel sheet. Is there a measure dax code I can use that would first add all the hours with the same person's name, and then take the average?

 

I was thinking of using AVERAGEX(SUMMARIZE('TABLE1', 'TABLE1'[COLUMN1], 'TABLE1'[COLUMN2),'TABLE1'[COLUMN2])

 

However, I am not sure this is giving me the correct values back. Any help? 

 

TL;DR How do I add all the hours with the same names firstm 

3 REPLIES 3
rsbin
Super User
Super User

@Anonymous ,

There are various ways to solve this.  Easiest way I think is:

Average = DIVIDE( SUM( 'Table'[hours] ),
                   DISTINCTCOUNT( 'Table'[names] ),
                   0 )

This will give you 7 / 2 = 3.5 hours.

Hope this will work with your full dataset.

Regards,

 

Anonymous
Not applicable

Yes, but I wanted to have the sum every value for the same person as well. 

 

What would that be?

@Anonymous ,

Hours_Sum = CALCULATE( SUM( 'Table'[hours] ),
                     ALLSELECTED( 'Table'[names] ))

rsbin_0-1699041824764.png

Is this what you are looking to achieve?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors