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! Request now

Reply
ViniciusGM
Frequent Visitor

Is there a measure to get the average of lines of a column filtered by a specific key value?

Hello guys, I hope this finds you well!

 

Well, I am considerably new to Power BI and I am struggling with creating a metric that disregards some columns from the data tables.

 

For a more illustrative view, follows the image of the data and my explanation as to what I intend to do:



Teste.PNG

 

This table shows the class in which a test has been done, the number of students in this specific class and the number of students that have done the test...

 

I want to find out the number of students that haven't done the test by class, which for example in the first row would be 30-25 = 5 students that did not do the test... but i want to group it by class disregarding the subject of the test and the key of the test. 

The measure i want to create would do something like, fixate the NU_STUDENT number by class and get an average of all rows of the NU_CONCLUDED_STUDENTS by class as well, using as an example the image i used previously, would be something like:

NU_STUDENTS by class AVERAGE OF ALL TESTS OF NU_CONCLUDED STUDENTS by class DIFFERENCE (Students that haven't done the test)
3023

 

If you can help me find a solution to this problem or even show to me why it is possible or not, I'd appreciate it very much!

Best Regards.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @ViniciusGM ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can create two measures as below:

 

Measure = 
VAR _ndstu =
    MAX ( 'Table'[NO_STUDENTS] )
VAR _avgconclude =
    AVERAGEX ( 'Table', 'Table'[NU_CONCLUDED_STUDENTS] )
RETURN
    _ndstu - _avgconclude
Difference = SUMX ( VALUES ( 'Table'[KEY_CLASS] ), [Measure] )

 

yingyinr_0-1654140431552.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi  @ViniciusGM ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can create two measures as below:

 

Measure = 
VAR _ndstu =
    MAX ( 'Table'[NO_STUDENTS] )
VAR _avgconclude =
    AVERAGEX ( 'Table', 'Table'[NU_CONCLUDED_STUDENTS] )
RETURN
    _ndstu - _avgconclude
Difference = SUMX ( VALUES ( 'Table'[KEY_CLASS] ), [Measure] )

 

yingyinr_0-1654140431552.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Thank you very much @Anonymous, that is exactly what I wanted!! And thank you for your suggestions for future posts as well!

Best Regards,
Vinicius

Anonymous
Not applicable

Hello

 

You can add a column with this code

difference = selectedvalue(Table1[NU_STUDENTS])-selectedvalue(Table1[NU_CONCLUDED_STUDENTS])

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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