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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
SebTsang
Frequent Visitor

How do I calculate an average of one column by filtering it through two other columns

I am trying to do an average calculation of the count per location per grade, please help.
Capture.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @SebTsang 

Try this code to build a calculated column.

Count Average Per Location and Grade =
CALCULATE (
    AVERAGE ( 'Sample'[Count] ),
    FILTER (
        'Sample',
        'Sample'[Location] = EARLIER ( 'Sample'[Location] )
            && 'Sample'[Grade] = EARLIER ( 'Sample'[Grade] )
    )
)

Result is as below.

1.png

If you want a measure, you can try this code.

Measure = 
CALCULATE (
    AVERAGE ( 'Sample'[Count] ),
    FILTER (
        ALL('Sample'),
        'Sample'[Location] = MAX ( 'Sample'[Location] )
            && 'Sample'[Grade] = MAX ( 'Sample'[Grade] )
    )
)

Result is as below.

1.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @SebTsang 

Try this code to build a calculated column.

Count Average Per Location and Grade =
CALCULATE (
    AVERAGE ( 'Sample'[Count] ),
    FILTER (
        'Sample',
        'Sample'[Location] = EARLIER ( 'Sample'[Location] )
            && 'Sample'[Grade] = EARLIER ( 'Sample'[Grade] )
    )
)

Result is as below.

1.png

If you want a measure, you can try this code.

Measure = 
CALCULATE (
    AVERAGE ( 'Sample'[Count] ),
    FILTER (
        ALL('Sample'),
        'Sample'[Location] = MAX ( 'Sample'[Location] )
            && 'Sample'[Grade] = MAX ( 'Sample'[Grade] )
    )
)

Result is as below.

1.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

MFelix
Super User
Super User

Hi @SebTsang ,

 

The best way is to use a measure just AVERAGE(Table[Column]) and then place the grades and the locaiton on your viusalization no need to create an additional column on your model.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors