2 Replies Latest reply on Dec 7, 2018 5:40 PM by Ritesh Bisht

# Visualizing number of months in between two dates?

Am wanting to visualize the number of months in between when a number of people started something and when they finished.

Currently the data is from Excel spreadsheet that has a row per person, and includes columns for end date and start dates.

Thinking a line graph or bar chart with ranges i.e. up to 12 months, 12-36 months, 37-60 months, 60 months +?

How would I go about doing this? Sorry for the question, am fairly new to Tableau and quite confused!

• ###### 1. Re: Visualizing number of months in between two dates?

Step 1:

 `DATEDIFF(date_part, date1, date2, [start_of_week])` Returns the difference between `date1` and `date2` expressed in units of `date_part`. The `start_of_week` parameter, which you can use to specify which day is to be considered the first day or the week, is optional. Possible values are 'monday', 'tuesday', etc. If it is omitted, the start of week is determined by the data source. See

You will do

month=

DATEDIFF ('month',startdate,end_date)

Above will give you a number of months for each row

Step 2

Now write a calculation like below

If month=12 then '12 months'

elseif month > 12 and month <= 36 then '12-36'

end

Step 3

Drag

Number of records to column & step 2 calculation to Rows

Please mark the answer as CORRECT and HELPFUL if it helps you so that it can help others as well

Ritesh

• ###### 2. Re: Visualizing number of months in between two dates?

Sample workbook attached

Ritesh