In Tableau, how do I use DATEDIFF to calculate number of days when there are null values in the data?
- Tableau FAQs
- December 13, 2018

DATEDIFF is a powerful feature that is often used in Tableau. DATEDIFF includes three required parameters (date level, start date, and end date). We can also use DATEDIFF in conjunction with an IF or CASE function. Here we are considering one such case:
IF
NOT ISNULL([DueDate])
THEN DATEDIFF(
'day', [DueDate], [StartDate])
ELSE 0
END
IF NOT ISNULL([DueDate]) – since we are faced with the task of counting days between only non-empty dates, here we use an expression where we check if the date is filled.
THEN DATEDIFF(‘day’, [DueDate], [StartDate]) -if the date is not empty, then we execute the DATEDIFF expression, where we count the number of days between two dates
ELSE 0 END – if the previous expression is FALSE then we print 0 and terminate our expression
That is how to use the DATEDIFF expression with null data values in Tableau.
Up Next:
Read What is the easiest way to make a calculation with a random group of orderid’s in Tableau?