Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
3 years ago

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

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

  • 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])
    )
  • 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