3 Replies Latest reply on Sep 23, 2018 3:01 PM by Fisseha Berhane

# Using Quantiles from R for coloring a Tableau Map

I have very skewed data (it follows approximately Pareto distribution). I want to map it and because of the skewness, the provided Tableau color options did not work for me.  I could have manually specified the max, center and steps and use a divergent color gradient. However, my map is dynamic. The values and their ranges significantly change based on my parameter selection. I thought using R to calculate quantiles (10% percentile, 20% percentile, ..., 90% percentile, and 100% percentile) would be good to handle this problems and as you can see in the image below, it looks to work fine for my purpose (I want to see various colors on the map). However, the problem I am facing is with the aggregation of the data that is sent to R and the results that come back to Tableau. My map is at DMA level. I have the group, order, lat and lon information for each polygon. So, I can map it at DMA level. I want to color it based on the quantiles from R. When i just create a Table with the DMA and the R quantiles, it works fine as you can see in the attached workbook, but I could not use the quantiles for coloring the map. I am using the EnvStats R package to create quantiles.

• ###### 1. Re: Using Quantiles from R for coloring a Tableau Map

Hi Fisseha Berhane ,

Try calculating it in tableau only ,you can do so .Please do not use external calculation unless you cant do it in tableau because it will reduce your performance .

DIV(INT(RANK_PERCENTILE(SUM([Population_2016]))),.1)

or

DIV(INT(RANK_PERCENTILE(SUM([Population_2016]))*100),10)

It will give you almost same result and better performance  i.e.  NewYork is having max population and this calculation will give NewYork  100 percentile .

or better use the step wise color using advanced option and select the center accordingly or you can create square root function .

-Nikher Verma

Please mark it right and helpful if this serves your purpose so that others can also get benefited & also to close the thread.

• ###### 2. Re: Using Quantiles from R for coloring a Tableau Map

Please use square root function on population and then step wise color coding using advanced options and set center accordingly .It's working perfectly fine for me .

• ###### 3. Re: Using Quantiles from R for coloring a Tableau Map

I was not familar with RANK_PERCENTILE . Can you share the workbook? Regarding your second comment, since my  data is dynamic and the range varies significantly based on my parameter selection, I cannot use hardcoded center.