Forum Discussion
Syndicate_Admin
3 years agoAdministrator
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).
The data table would be similar to the following. I thank you for your help.
Best regards
| Evaluation | Index | Student | NotaMediaAlumno | Active | Subject | Note |
| First Evaluation | 1 | Alumno01 Alumno01 Alumno01 | 3,857142857 | Active | BADAT | 4 |
| First Evaluation | 1 | Alumno01 Alumno01 Alumno01 | 3,857142857 | Active | END | 2 |
| First Evaluation | 1 | Alumno01 Alumno01 Alumno01 | 3,857142857 | Active | FOL | 7 |
| First Evaluation | 1 | Alumno01 Alumno01 Alumno01 | 3,857142857 | Active | LEUP | 7 |
| First Evaluation | 1 | Alumno01 Alumno01 Alumno01 | 3,857142857 | Active | LMSGI | 4 |
| First Evaluation | 1 | Alumno01 Alumno01 Alumno01 | 3,857142857 | Active | PROGR | 1 |
| First Evaluation | 1 | Alumno01 Alumno01 Alumno01 | 3,857142857 | Active | INNERMOST | 2 |
| First Evaluation | 2 | Alumno02 Alumno02 Alumno02 | 4,833333333 | Active | BADAT | 5 |
| First Evaluation | 2 | Alumno02 Alumno02 Alumno02 | 4,833333333 | Active | END | 2 |
| First Evaluation | 2 | Alumno02 Alumno02 Alumno02 | 4,833333333 | Active | FOL | null |
| First Evaluation | 2 | Alumno02 Alumno02 Alumno02 | 4,833333333 | Active | LEUP | 8 |
| First Evaluation | 2 | Alumno02 Alumno02 Alumno02 | 4,833333333 | Active | LMSGI | 7 |
| First Evaluation | 2 | Alumno02 Alumno02 Alumno02 | 4,833333333 | Active | PROGR | 2 |
| First Evaluation | 2 | Alumno02 Alumno02 Alumno02 | 4,833333333 | Active | INNERMOST | 5 |
2 Replies
- igrandey89Advocate II
what is the current measure that you created?
Maybe tryAverage Grade per Subject = CALCULATE( AVERAGE('Table'[Note]), 'Table'[Active] = "Active" || 'Table'[NotaMediaAlumno] > 1, ALLEXCEPT('Table', 'Table'[Subject]) ) - Syndicate_AdminAdministrator
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 notAverageActiveGrade1 = 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 filterAverageAssetsOK = 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