2 Replies Latest reply on Apr 9, 2018 6:47 PM by Mike Mainzer

# Counting the number times a record in one column matches/doesn't match the item in the same row of another column?

Hi! I'm new to Tableau, and am practising with a dataset about Nobel Prize winners. I've got one column with the country of birth for each winner (column B), and another with country of death (column D). I'd like to find the total number of winners who migrated -- that is, whose country of birth is different from their country of death. So, I need to count the number of instances in which an item in column B does not match the item in the same row of column D. Can anyone advise? (I'm working with Tableau Public.)

• ###### 1. Re: Counting the number times a record in one column matches/doesn't match the item in the same row of another column?

Sarah,

I would try:

IF [Column B] =! [Column D] THEN 1 END

This should give you what you're looking for. Let me know if you run into issues.

-Wesley

If this post assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

1 of 1 people found this helpful
• ###### 2. Re: Counting the number times a record in one column matches/doesn't match the item in the same row of another column?

See operators syntax here: Formatting Calculations in Tableau

Tableau has two not equal operators: '<>', and '!='.

So IF [Column B] <> [Column D] THEN 1 END

OR

IF [Column B] != [Column D] THEN 1 END

Either of these will work.

So, to make a table:

1. Create your calculated field - either of the above will work

2. Drag your 'Winners' dimension to Rows

3. Drag 'Measure Names' to filter and select the calculated field you just made

4. Drag 'Measure Names' to Columns

5. Drag Measure Values to text

6. Make sure your calculated field is set to SUM (it should do this automatically)

1 of 1 people found this helpful