First question, is each event record in its own row, or are all the events in one row...does the data look like:
id1 event1
id1 event2
or
id1 event1 event2
if the later, the mrc161 solution might work (only because of subtracting dates, I am not sure of)
If the former, that solution won't work.
first quick primer on variables. 3 types, local, global, and shared. if you using a variable, just in the formula and don't need that value anywhere else use local, otherwise use shared. Global isn't as global as shared. To 'create' a variable, just put in the formula: shared variabletype variableName. Look in help to find the different variables names. That is all there is to using variable...be careful, they are case sensitive. = test for equality, := assigns a value
Back to the solution if the events are not all in one row. You will need a group of some kind, probably by customer contact. then the standard 3 formulas should suffice. 1 in group header seting the variable to a value like:
shared datetimevar start:="1/1/1900";
shared datetimevar ending:="1/1/1900";
""//hides the calculations
1 in the details section like;
shared datetimevar start;
shared datetimevar ending;
if event=2 then start:={table.creationdate};
if event=4 then ending:={table.creationdate};
""
1 in the group footer like:
shared datetimevar start;
shared datetimevar ending;
if start="1/1/1900" or ending="1/1/1900" then
0
else
datediff(hour, start, ending)
hopefully this is along the right path. You might want to try the subtraction for the dates or different value (days, minutes..look in help)