Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all, can anyone help me to solve my issue:
i need to calculate time difference in days for one id but different events. My table looks like this:
I need to calculate time difference only for events 1 and 2.
Thanks in advance for hints!
Create an additional field in your load script. Try with the script below to see if the output is what you are looking for.
Set dateformat = 'DD/MM/YY';
Table:
Load * inline [
product, event, dates
product a,1,11/02/21
product a,2,15/02/21
product b,1,10/02/21
product b,2,10/02/21
product b,3,12/02/21
];
Load
product,
event,
dates,
If(event = 2, Interval(dates - Previous(dates), 'D')) as date_diff
Resident Table
;
drop Table Table;
Can you show the expected output with the sample above?
provide some more data, also provide desired output.
Hi all, here's some more data with expected result table
I guess I need to calculate another table, but would be grateful for other ideas)
You can use a pivot table (see attachment for desired output). The value fields were created in the load script using the provided data and the if statement below:
If(event='event 2', Interval(dates - Previous(dates), 'D')) as [Event 2-1]
If(event='event 3', Interval(dates - Previous(dates), 'D')) as [Event 3-2]