Forum Discussion

WJ876400's avatar
WJ876400
Helper IV
6 years ago
Solved

Measure for colour coding

Hi

 

I have the below table, it shows  3 students and 3 modules, each module has two elements to it. The 4th column shows what % that contributes to the grade.  Below is what I have done on excel and the formulas I have used and I am looking to replicate this on BI.

 

What I want to do is calculate-

the weighting Factor which is =D2/240

Marks towards Total Grade =(E2*F2/SUM(F2:F7)

Total Mark =SUM(G2:G7)

RAG Status  =IF(COUNTIF(E2:E7,"<40")>0,"Red",IF(AVERAGE(E2:E7)>=60,"Green","Amber"))

 

I am struggling with how to do the sums for each student, to count the six rows for each stucdent and get the Marks towards total grade and Total Mark and RAG status.

 

Hope this makes sense any help would be greatly appreciated 

 

 

 ABCDEFGHI
1NameModuleTypeWeighting towards 100% ModuleMarkWeighting FactorMark towards total GradeTotal MarkRAG Status
2Student 11Coursework70500.29166666711.6666666754.78333333Red
3Student 11Exam30600.1256  
4Student 12Coursework50380.2083333336.333333333  
5Student 12Exam50280.2083333334.666666667  
6Student 13Coursework65710.27083333315.38333333  
7Student 13Exam35920.14583333310.73333333  
8Student 21Coursework70700.29166666716.3333333379.95Green
9Student 21Exam30670.1256.7  
10Student 22Coursework50890.20833333314.83333333  
11Student 22Exam50900.20833333315  
12Student 23Coursework65900.27083333319.5  
13Student 23Exam35650.1458333337.583333333  
14Student 31Coursework70450.29166666710.551.03333333Amber
15Student 31Exam30520.1255.2  
16Student 32Coursework50480.2083333338  
17Student 32Exam50510.2083333338.5  
18Student 33Coursework65600.27083333313  
19Student 33Exam35500.1458333335.833333333  
  • Hi WJ876400 

     

    I just renamed the measures so you can tell them. 1 point need to confirm that Total Mark =SUM(G2:G7) you mentioned before should be named as Total Mark towards Total Grade (I use TotalMarkTowards in measure), and the real Total Marks = SUM(E2:E7)

     

    Then total Mark Towards for each Student which adds up their marks towards total grade =: 

    Measure = [Marks towardsTotalGrade]+[ToTalMarktowards]

    And the conditional color based on it. do you mean like this below?

    You can refer to this similar post for reference: https://community.powerbi.com/t5/Desktop/Conditional-formatting-on-Strings-table-cells/td-p/784516

5 Replies

  • v-diye-msft's avatar
    v-diye-msft
    Community Support

    Hi WJ876400 

     

    Based on your logic, please use below measures:

    Measure = CALCULATE(SUM('Table (2)'[Mark]),ALLEXCEPT('Table (2)','Table (2)'[Name]))
    Measure 2 = MAX('Table (2)'[Weighting towards 100% Module])*MAX('Table (2)'[Mark])/[Measure]
    Measure 3 = CALCULATE(SUM('Table (2)'[Weighting Factor]),ALLEXCEPT('Table (2)','Table (2)'[Name]))
    Measure 4 = var a = CALCULATE(COUNT('Table (2)'[Mark]),FILTER(ALLEXCEPT('Table (2)','Table (2)'[Name]),[Mark]<40))
    var b = CALCULATE(AVERAGE('Table (2)'[Mark]),ALLEXCEPT('Table (2)','Table (2)'[Name]))
    Return
    IF(a>0,"Red",IF(b>=60,"Green","Amber"))

     

    PBIX attached.

    • WJ876400's avatar
      WJ876400
      Helper IV

      Hi v-diye-msft 

       

      Thank you for sending this i will work through it and see if it works. How do I get a total Mark for each Student which adds up their marks towards total grade? And then have the colour based on that?

       

      thanks again

      • v-diye-msft's avatar
        v-diye-msft
        Community Support

        Hi WJ876400 

         

        I just renamed the measures so you can tell them. 1 point need to confirm that Total Mark =SUM(G2:G7) you mentioned before should be named as Total Mark towards Total Grade (I use TotalMarkTowards in measure), and the real Total Marks = SUM(E2:E7)

         

        Then total Mark Towards for each Student which adds up their marks towards total grade =: 

        Measure = [Marks towardsTotalGrade]+[ToTalMarktowards]

        And the conditional color based on it. do you mean like this below?

        You can refer to this similar post for reference: https://community.powerbi.com/t5/Desktop/Conditional-formatting-on-Strings-table-cells/td-p/784516