A simplified example of the database has been set up here:
https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=078d09c494bdfd18374bdf81d61d19a5
Thanks to stackoverflow i did achieve it in sql using the following query:
COALESCE(loadedTime.date, pendingTime.date) AS time_stamp
FROM [order] o
JOIN orderstatus pendingTime
ON pendingTime.orderid = o.orderid
AND pendingTime.type = 110
LEFT JOIN orderstatus loadedTime
ON loadedTime.orderid = o.orderid
AND loadedTime.type = 160
Now the challenge in Qlik is that i first have to build up my order table. After the order table we build up the orderstatus table from a different data source. After this i should somehow query the orderstatus and extend the order table with a new field; completeDate field with the result returned from the above query.