4 Replies Latest reply on Nov 7, 2018 1:17 AM by Roger Pouly

# I have different products ordered in different dates with the same order ID. How can I compare their order dates ?

Hello everyone,

Let's take this exemple :

I would like to check the differences between the beginning or the trip of the order and the food order : In this case, 3 days.

Any way I can do this ? I would have two calculated fields, one for the difference between beginning of the trip and Food, and one with Extra Demands,

You can find a workbook with an exemple attached.

Thanks,

Roger

• ###### 1. Re: I have different products ordered in different dates with the same order ID. How can I compare their order dates ?

Datediff formula will get you the difference between two dates

Datediff('day',[day of beginning],[day of product order]).

Use this calculated measure on the report to get the exact difference.

• ###### 2. Re: I have different products ordered in different dates with the same order ID. How can I compare their order dates ?

Hi Roger,

Recommend you to go through --->Date Functions - Tableau

 DATEDIFF `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 Date Properties for a Data Source.Supports ISO 8601 dates. Examples:`DATEDIFF('week', #2013-09-22#, #2013-09-24#, 'monday')= 1` `DATEDIFF('week', #2013-09-22#, #2013-09-24#, 'sunday')= 0`The first expression returns 1 because when `start_of_week` is 'monday', then 22 September (a Sunday) and 24 September (a Tuesday) are in different weeks. The second expression returns 0 because when `start_of_week` is 'sunday' then 22 September (a Sunday) and 24 September (a Tuesday) are in the same week.

Thanks,

Ritesh

• ###### 3. Re: I have different products ordered in different dates with the same order ID. How can I compare their order dates ?

Good morning Ritesh Bisht, Akram Ebrahim.

Thank you for your answers. I already do know how to check the differences between two dates, but in this case it is a bit more complex, as the Order ID is not the primary data of the workbook. Every line of my workbook has an Unique ID (product level), and one Order ID can have several Unique ID (several products attached).

Would you mind try to do it with the workbook I enclosed ?

Thank you both,

Roger

• ###### 4. Re: I have different products ordered in different dates with the same order ID. How can I compare their order dates ?

To clarify a little bit, the two dates I want to compare are from the field Date of Product Order (but only when it is 'Food' or 'Extra Demands') and the beginning of the trip.