How does Tableau recognize “is not null” in a calculated field? How do I write a formula to return all non-empty data?
- Tableau FAQs
- December 12, 2018
Tasks with defining null values in both string and integer formats are quite common tasks in data analysis. In Tableau, you can easily calculate these values with the strongest IF function. Imagine that you are faced with identifying employees who do not have a middle name, and this function will help to do this. You can use the following expression:
IF ISNULL([MiddleName])
THEN 'empty middle name'
ELSE 'there is the middle name'
END
IF ISNULL([MiddleName]) – here, we specify a condition in which the ISNULL function will check if the field is empty and output TRUE or FALSE. Note that this time we do not specify what the expression should be equal to because ISNULL always returns the result in Boolean format.
THEN ’empty middle name’ – if, when checking the data for the presence of empty values, ISNULL returns TRUE, then we display the text value, or we can display something else.
ELSE ‘there is middle name’ – if ISNULL outputs FALSE, then we must show another result of the function execution, and here we also indicate the text
END – and as usual, the IF function must be closed with END
Then you can show the number of employees who have a report or not for this. You can also use the IF function and then show it in some Bar Chart or Pie Chart.
Up Next:
Read How to create calculated field that is based on group by value in Tableau?