5 Replies Latest reply on Feb 15, 2016 7:23 PM by lei.chen.0

# Calculated field using string formula?

Hi,

I have a dimension called "Gender" with two possible values: "M" and "F". One of my views (below) uses a table calculation to show the gender breakdown of about 400 government organizations.

I want to sort the organizations by the proportion of male or female employees.

I created a calculated field called "% male" to sort on. The formula is:

count([Gender]="M")/[Number of Records]

I've also tried a lot of variations in case my syntax is off - more parentheses, single rather than double quotes, things like that. But in the end this formula always yields a value of 1. The numerator yields the same value as the denominator.

Does anyone have any idea why this formula doesn't work and how I might create one that does?

Thank you.

Dan

• ###### 1. Re: Calculated field using string formula?

Dan,

Hopefully this may help:

• ###### 2. Re: Calculated field using string formula?

Thank you, Pooja, and that certainly looks promising. I got as far as Step 6, after I chose "sort" and was asked to fill out the sort dialog box. I was confronted with this:

...a blank sort dialog box. Clearly there is some problem communicating with the underlying data. I will try refreshing the extract and see what transpires.

This is the story of Tableau for me: Something that appears easy on the surface easy ends up taking days. And sorting is one of the worst offenders. I know there is some Excel bashing these forums, but at least Excel is transparent.  Frankly, after grappling with this seemingly simply problem for some time, I am discouraged.

Dan

• ###### 3. Re: Calculated field using string formula?

Hello Dan,

I got the same as you, but it doesn't matter.

This KB helps you sort the gender proportion within each organization.

While your requirement is to sort organization by gender proportion.

This can be achieved by calculation field.

I attached a sample workbook using the data from HR Analytics (Polices) as sample.

Regards.

• ###### 4. Re: Calculated field using string formula?

Hello, Lei Chen, I am a student of analytics and new to this forum, I am working on a project on HR analytics. Can you please share a sample HR data excel sheet which can be used in Tableau. thanks in advance also let me know where can i find HR analytics demo tutorial using tableau @lei chen

• ###### 5. Re: Calculated field using string formula?

Hello SAIKAT,

Again, I recommend the sample datasets in the 3 HR analysis samples of Tableau,

which are in the form of Tableau extract,  not Excel file, but you still can use Tableau Desktop to viz them

Here's another dataset, hoping it'll be helpful for you.

Regards.