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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
sammy3
New Member

Creating a column average based on two other columns

Hello,

 

I need some assistance in finding a solution to this problem. I want to create a column that would display the average of [Value] based on [ID] if the [Location] column has common values. Please see example below. Thank you kindly

 

 

sammy3_0-1612766496844.png

 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @sammy3 ,

 

Create a measure as below:

 

 

Measure = CALCULATE(AVERAGE('Table'[value]),FILTER(ALL('Table'),'Table'[ID]=MAX('Table'[ID])&&'Table'[Location]=MAX('Table'[Location])))

 

 

Or you could create a calculated column as below if needed :

 

 

Column = CALCULATE(AVERAGE('Table'[value]),FILTER('Table','Table'[ID]=EARLIER('Table'[ID])&&'Table'[Location]=EARLIER('Table'[Location])))

 

 

And you will see:

 

v-kelly-msft_0-1613011968665.png

 

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

3 REPLIES 3
v-kelly-msft
Community Support
Community Support

Hi @sammy3 ,

 

Create a measure as below:

 

 

Measure = CALCULATE(AVERAGE('Table'[value]),FILTER(ALL('Table'),'Table'[ID]=MAX('Table'[ID])&&'Table'[Location]=MAX('Table'[Location])))

 

 

Or you could create a calculated column as below if needed :

 

 

Column = CALCULATE(AVERAGE('Table'[value]),FILTER('Table','Table'[ID]=EARLIER('Table'[ID])&&'Table'[Location]=EARLIER('Table'[Location])))

 

 

And you will see:

 

v-kelly-msft_0-1613011968665.png

 

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

This works perfectly but is then impacted by my page filters.  If I add the column in the Power Query Filter I assume the filters added later in the desktop will not change the value but I'm struggling to translate to DAX

amitchandak
Super User
Super User

@sammy3 , Try like

calculate(Average(Table[value]), allexpect(Table, Table[ID], Table[Location]))

or

calculate(Average(Table[value]), filter(allselected(Table), Table[ID] =max(Table[ID]) && Table[Location] = max(Table[Location])))

or

averageX(summarize(Table, Table[ID], Table[Location],"_1",Average(Table[value])),[_1])

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.