4 Replies Latest reply on Dec 12, 2016 8:59 AM by subodh Thapliyal

# How to find difference in data for start and end time in day?

Hi

I am trying to show difference in data for start and end time selected by datetime filter.

eg:- I have data for three days 1/12,1/13, and 1/14 with date time. If i plot set a viz for daily view, the sale should show the difference between 12:00:00 AM and 11:59:59 PM for each day.

the result should be one value which will be the difference of value at 11:59:59 PM (or max time) and 12:00:00 Am (or min time) for each day. Similarly if i plot weekly view then data should be

(max time for end of week) - (min time for start of week).

Thanks

• ###### 1. Re: How to find difference in data for start and end time in day?

I think I understand what you want. You will have a filter for a time period and want to the the value from the beginning of the period and the value from the end of the period and calculate the difference?

Assuming that is the case you can get the earliest time by this formula:

{MIN([Date])} or {FIXED:MIN([Date])} - these formulae are both exactly the same

For the last (or max) date change the formula to be MAX - i.e. {MAX([Date])}

To return the value of the min date:

IF [Date] = {MIN([Date])} THEN [Value] END

and the value of the max date, IF [Date] = {MAX([Date])} THEN [Value] END

Your final calculation could be SUM(IF [Date] = {MAX([Date])} THEN [Value] END) - SUM(IF [Date] = {MIN([Date])} THEN [Value] END)

• ###### 2. Re: How to find difference in data for start and end time in day?

Hi

Andrew,

Thank you very much for your response, but this solution work best for only one parameter.

If i have 20 parameter to show and need to find difference in each, how will it work.

Will greatly appreciate if you can attach a workbook as an example.

Subodh

• ###### 3. Re: How to find difference in data for start and end time in day?

Using your example dates I've published an example to Tableau public: https://public.tableau.com/views/EarliestAndLatestTimePeriodDifference/Differencebetweentimeperiods?:embed=y&:display_co…