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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Syndicate_Admin
Administrator
Administrator

Problems with a DAX measure

Hi, I have a problem creating a DAX measure to calculate the average per subject of the grades of a group of students. The measure will be used, in principle, in a visual object of grouped columns and lines in which the subject will go on the X axis, in the Y axis the note on the Y axis of line the average grade of the subject. In the report there will be a segmentation by student and by evaluation.

The average grade of the subject will be that of all active students (Active = "Active" or AverageStudent>1, both are calculated columns of the table).

gráfica.png

The data table would be similar to the following. I thank you for your help.

Best regards

EvaluationIndexStudentNotaMediaAlumnoActiveSubjectNote
First Evaluation1Alumno01 Alumno01 Alumno013,857142857ActiveBADAT4
First Evaluation1Alumno01 Alumno01 Alumno013,857142857ActiveEND2
First Evaluation1Alumno01 Alumno01 Alumno013,857142857ActiveFOL7
First Evaluation1Alumno01 Alumno01 Alumno013,857142857ActiveLEUP7
First Evaluation1Alumno01 Alumno01 Alumno013,857142857ActiveLMSGI4
First Evaluation1Alumno01 Alumno01 Alumno013,857142857ActivePROGR1
First Evaluation1Alumno01 Alumno01 Alumno013,857142857ActiveINNERMOST2
First Evaluation2Alumno02 Alumno02 Alumno024,833333333ActiveBADAT5
First Evaluation2Alumno02 Alumno02 Alumno024,833333333ActiveEND2
First Evaluation2Alumno02 Alumno02 Alumno024,833333333ActiveFOLnull
First Evaluation2Alumno02 Alumno02 Alumno024,833333333ActiveLEUP8
First Evaluation2Alumno02 Alumno02 Alumno024,833333333ActiveLMSGI7
First Evaluation2Alumno02 Alumno02 Alumno024,833333333ActivePROGR2
First Evaluation2Alumno02 Alumno02 Alumno024,833333333ActiveINNERMOST5
2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

I tried several ways; I was working on two:

AverageGrade = CALCULATE(AVERAGE(Assessments[Note]), REMOVEFILTERS(Assessments[Student]))
It calculates the average for all students, whether active or not
AverageActiveGrade1 = CALCULATE(AVERAGE(Evaluations[Note]),FILTER(Evaluations,Evaluations[Active]="Active"),REMOVEFILTERS(Evaluations[Student]))
In this case it does not eliminate the filter of the segmentation of students so it returns the student's grade in the module, I interpret that REMOVEFILTERS also affects the explicit filter that I indicate in the measure...
I think I just solved the problem, I share it in case it can serve someone else. It goes through using KEEPFILTERS to apply the active student filter
AverageAssetsOK = CALCULATE(AVERAGE(Evaluations[Note]),KEEPFILTERS(Evaluations[Active]="Active"),REMOVEFILTERS(Evaluations[Student]))
In principle the results it offers me are correct, I do not know if it will have other implications if I use it in another visual object ...
Thanks anyway
igrandey89
Advocate II
Advocate II

what is the current measure that you created?

Maybe try

Average Grade per Subject = 
CALCULATE(
    AVERAGE('Table'[Note]),
    'Table'[Active] = "Active" || 'Table'[NotaMediaAlumno] > 1,
    ALLEXCEPT('Table', 'Table'[Subject])
)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.