Question

Count and Graph the Number of Different Calculation Results

• 2 replies
• 128 views

I have a list of assessment scores that are grouped into tiers (1 thru 7) based off of how many standard deviations the score is away from the population mean (see tier calculation below). I want to be able to count how many clients are in each tier and then display that in a bar graph. The priority tiers are currently displayed in their own calculation column. I want to use a countif() function, but that is not an option. Is there something simple I am missing?

Priority Tier Calculation:

if(\${stdev_away_from_mean}>3,1,if(\${stdev_away_from_mean}>2,2,if(\${stdev_away_from_mean}>1,3,if(\${stdev_away_from_mean}>0,4,if(\${stdev_away_from_mean}>-1,5,if(\${stdev_away_from_mean}>-2,6,7))))))

2 replies

Userlevel 3

Hi @Michael_Reed,

You have a couple of options:

1. Put your tier logic into the LookML (you could use the case parameter as documented here: https://docs.looker.com/reference/field-params/case). Then you can use a simple count measure with your tier dimension. If you have developer permission, I would recommend this option both for simplicity and for future usability.

2. This is possible to do in calculations by using a statement like sum(if(logic,1,0)), but you’d want to create seven of these statements and nest them in another if statement as you did in your first calculation, then add on a statement like + \${count} * 0 to make Looker treat your new calc column as a measure and allow it to show up in the visualization. This is more “hacky” but should achieve your immediate goal.

Thanks Chris! I will give it a try.