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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
cmc099
Frequent Visitor

Measure to find average of areas based on ID

Hi there,

 

I'm having an issue with something that I think should be easy. I have a table that looks something like the following,

 

Unique row IDHouse IDHouse area
11100
21100
32200
42200
52200
6350
73

50

 

What I want to do is create a measure that finds the average area of all houses. The house area is always the same for each row with identical house ids. I essentially want to group the houses by their house ids and only keep one instance of its area, then find the average of these. So, for my example table above, I want my measure to output (100+200+50)/3 = 116.67.

 

I don't want to reduce my table down to just three rows as there are actually way more columns in my actual table that give me different information on the rooms of the house. I have tried calculating using sums and filters but cannot get it to work. I think that within the measure, I'll have to summarize a table that groups all the IDs, then find the average of the area column, but I'm not entirely sure how to do this. Any suggestions? Any help is much appreciated.

1 ACCEPTED SOLUTION

@cmc099 Then use:

Measure = AVERAGEX(DISTINCT(SELECTCOLUMNS('Table',"__ID",[House ID],"__Area",[House Area])),[__Area])

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@cmc099 Try:

Measure = AVERAGEX(DISTINCT('Table'),[House area])

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler That still gives me the same issue I've been having unfortunately. The example table I included doesn't include all of the columns that are actually in my table, so every row isn't the exact same even if they share the same House ID, so when I use that measure on my actual table it calculates the mean like, (100+100+200+200+200+50+50)/7, which I don't want, I want to filter by distinct values of the house ID, but I'm not sure how to do this. I've updated the example table with a better view of my actual table now.

@cmc099 Then use:

Measure = AVERAGEX(DISTINCT(SELECTCOLUMNS('Table',"__ID",[House ID],"__Area",[House Area])),[__Area])

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Yes! Thank you! That works perfectly

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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