Search code examples
multiple-columnstableau-apidivide

tableau divide one measure by another


I have data like below in Tableau.

school  student marks
a       xy      5
a       xy      10
a       ab      15
b       cd      20
b       cd      25
a       cd      30

I want to find total marks, count of marks and average marks by student and school

in case of the below two tables i was able to create first 3columns, how could i create the 4th column? 2nd and third columns are measures. Is it possible to perform a row level calculation?

student sum of marks    count of marks  average marks
xy      15              2               7.5
ab      15              1               15
cd      75              3               25

school  sum of marks    count of marks  average marks
a       60              4               15
b       55              2               27.5

Solution

  • Yes, you can create a calculated field as "average marks":

    SUM(marks)/COUNT(marks)
    

    Or simply select average of that measure, instead Sum or Count (right click, Measure: Average)