1 Reply Latest reply on Mar 16, 2016 6:54 AM by Louis-Marius Gendreau

    Calculate tercile (or quantile or...) using a calculated field

    Louis-Marius Gendreau

      I've seen some discussions on this but they were previous to the rank_percentile() function.


      So, I am trying to separate a bunch of data points in 3 equal size groups.  It's easy to do by adding the tercile distribution line on the graph, but I want to calculate the actual group a point belongs to using a calculated field:  each point would be assigned group 1, 2 or 3. 


      I can easily get the percentile with rank_percentile() but each time I try to use that in a calculation to see if the point is in the first, second or third third, the calculation breaks down and does not work.  Whether I use a CASE to try to return one of three groups or a formula like INT(rank_percentile(value)/.34) it does not work.


      Here is some example data to where I tried to classify each country by tercile of "number of homicides" and I just can't get that number.


      Thank you so much!