Assign a label to a Grouped Value

Hi community!

I am doing an analysis on a dataset which contains the answers of a set of students of the questions of an exam. On the dataset, I have the following columns:

  • “Student ID” which contains the unique identifier of each student that did the exam
  • “Score” which contains only 0’s and 1’s. This column will have the value “1” if the student answer the question correctly, or “0” if the student didnt got the right asnwer.

What I am trying to achieve is a Bar Chart that give me how many students got the score between certain intervals, and assign a letter to that specific interval like:

0 <= Score < 3 → ‘D’
3 <= Score < 5 → ‘C’
5 <= Score < 8 → ‘B’
8 <= Score < 9 → ‘A’

To acheive this, I created the following ifelse expression:

ifelse({score} >= 0 AND {score} < 3, 'D', {score} >= 3 AND {score} < 5, 'C', {score} >= 5 AND {score} < 8 ,'B', 'A')

Then, when I try to plot this Calculated field with the Count of the Student ID, I got the following result:

image

This suggests that my expression is not aggregating the Score by Student ID. What I did after, was to create the following Calculated Field to use on the expression given before instead of the column “Score”.

maxOver
(
     sum({Score}),
     [{Student id}]
)

But when I try to replace the “Score” expression on the first Calculated field with this new field, the plot doesnt show anything.

image

Does anyone know how I can make this aggregation to work so that the bar chart displays the number of students that got the assigned grades (A,B,C and D) ? Many thanks :slight_smile:

Hello @MiguelA !

That error message means that your visual is missing a field it needs to chart the data. My assumption is that you are running into that because of your maxOver function. Have you applied any filters to your analysis?

I was able to achieve this with your ifelse function:

Grade = ifelse({score} >= 0 AND {score} < 3, 'D', {score} >= 3 AND {score} < 5, 'C', {score} >= 5 AND {score} < 8 ,'B', 'A')