Forum Discussion

diogobraga2's avatar
diogobraga2
Helper IV
6 years ago
Solved

Calculate Straight or Weighted Average for the Total

The dataset has grade level data for schools (subset shown below).
The goal is to calculate percentage of total for each grade AND for the whole school using this dataset. 

Percent Enrolled = Total Students / Target

SchoolAcademic YearGradeTotal StudentsTargetPercent Enrolled
A2019-2020K1001001
A2019-202011001001
A2019-202021001001
A2019-202031011001.01
A2019-202041001001
A2019-202051001001
A2019-20206100951.052631579
A2019-2020799951.042105263
A2019-2020895951

 

The grade level calculation works as show above and below:

The issue is when I remove grades to calculate the percent of total for the school, when I try AVG it does not work properly. What am I doing wrong and what is the recommended way of doing this? What is the best practice to calculate straight and weighted average for the total when there is a dimension like 'grades' in this example. 

 

  • Hi diogobraga2 ,

     

    As the error message, In your formual,  DISTINCTCOUNT should not be used like thay, please refer to my formula again.

    Measure 2 = 
    SUMX ( 'Table', [Measure] ) / DISTINCTCOUNT ( 'Table'[Grade] )

     

    Or you can share your pbix to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

     

8 Replies

    • diogobraga2's avatar
      diogobraga2
      Helper IV

      I tried avereging the calculation listed on the post: Percent Enrolled = Total Students / Target

       

       

      • diogobraga2's avatar
        diogobraga2
        Helper IV
        This is the actual calcution:
        % Total Enrolled M = if(student_status_count[Total Students M]/student_status_count[Target M]>0,student_status_count[Total Students M]/student_status_count[Target M],0)