3 Replies Latest reply on Nov 19, 2018 7:01 AM by K Chandler

# Show a simplified ratio on a dashboard

Hi

I would like to show the ratio of female to male employees as a simplified ratio in the form female:male on a dashboard. While it is easy to show actual number of females:actual number of males, I am struggling to work out how to put this in a simplified form, e.g. 5 females and 10 males is a ratio of 1:2. Does anyone know a way to determine the greatest common factor of both sums so that I can then use that to calculate the simplified ratio?

The data comprises 1 row per person, e.g.

name       gender

fred          male

susan      female

john         male

....

Thanks

K

• ###### 1. Re: Show a simplified ratio on a dashboard

Hi K,

Find my approach as reference below and stored in attached workbook version 2018.2 located in the original thread

1. M1. Female: {fixed: sum(if ([Gender])='female' then 1 END)}

2. M2. Male: {fixed: sum(if ([Gender])='male' then 1 END)}

3. D1. Ratio: '1 : '+ mid(str(([M2. Male])/([M1. Female])),1,4)

Ps roundings could be done nicer;)

Regards,

Norbert

1 of 1 people found this helpful
• ###### 2. Re: Show a simplified ratio on a dashboard

I believe that this post was for the same question: How can I reduce a fraction to its lowest / simplest form in Tableau?

I agree with Joe's assessment - Tableau's calculated fields were not designed for looping calculations. The only recommendation I would add is that this should be quite easy to do in R (see the "fractions" function in the MASS package), so leveraging Tableau's SCRIPT_ functions may be of use here.

1 of 1 people found this helpful
• ###### 3. Re: Show a simplified ratio on a dashboard

Thank you Norbert and Stephen. Both suggestions are helpful, i.e. either constrain the first number to 1 or try to get the common factor using R. I'll give both a go and see which works best for what I'm doing.