Skip to main content
Announcements
Qlik Community Office Hours - Bring your Ideation questions- May 15th, 11 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
pdufs40x
Contributor
Contributor

Conditional return of datafield

I got a table named "Order", an order has multiple child records in the table "OrderStatus". The orderstatus contains steps following the progress of an order. The orderstatus contains a datetime field holding a timestamp when the specific status was finialized.

I need to get the datestamp of a specific type of status (say 160) -IF- it exists for the order, otherwise fallback to the date of status 110 (which should always be present).

 

A simple example of the datebase 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:

select o.OrderId, 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

 

 

1 Reply
Brett_Bleess
Former Employee
Former Employee

Laurent, likely going to need to attach a sample QVW file on this one in order for someone to offer up suggestions, as I am not sure the SQL query is going to be enough for them to sort it in QlikView.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.