2 Replies Latest reply on Aug 21, 2016 10:45 AM by Mikel S

# Null values and difference calculation

Hi! I'm new to Tableau. I want to do a simple thing but I am struggling to get the results I expect.

I want to get the difference of the number of records depending  on one dimension.

This is an example with fake data:

I want to get the difference of number of records between men and women, eg:

Nationality
SportDifference
ANGaquatics0
athletics0
handball15
judo1
rowing-2
sailing-3
shooting-1

But I can only get the following:

As you can see, for handball there are no men taking part and I get an empty cell instead of 15 (15-0). And for sailing there are no women taking part, instead of getting a -3 (0-3) I cannot even show the sport. These are the properties of the quick calculation:

Attached the data and the twb.

Thank you!

• ###### 1. Re: Null values and difference calculation

Hi Mikel,

The easiest way to do this is:

1. create a calculated field to calculate male number of records:

IF [***] = 'male' THEN [Number of Records]

ELSE 0

END

2. Repeat for females

IF [***] = 'female' THEN [Number of Records]

ELSE 0

END

3. Create calculated field to find the difference:

[Female-Records]-[Male-Records]

I have attached some screenshots for your reference.

Hope this helps.

Suraj.

• ###### 2. Re: Null values and difference calculation

Thank you!