Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
wbatarfi
Contributor
Contributor

Cacluate two column and use if experssion

I have two fields  'Created_Time' and 'Resolved_time'.

1- I want to add a calculated field as "Time".  my expression was  : [Resolved_time - Created_Time] but the result is zero, I'm not sure why although the two columns are in date format in data source excel sheet.

2- I want also to add a column " order Status" depending in the Time results above. if the time calculated then the status "closed". if it's null then the status "Open"

 

Created_TimeResolved_timeTime in days and hoursstatus
23/07/2018 19:3024/07/2018 10:30  
02/09/2018 13:11-  
01/11/2018 12:4501/11/2018 3:45  
1 Solution

Accepted Solutions
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

Add in timestamp formatting in your load script, possibly QV reading the timestamp as string:

LOAD *,
Resolved_time-Created_Time as [Time in Days & Hours],
if(isnull(Resolved_time)or len(Resolved_time)<=1,'Open','Closed') as Status;
load
timestamp#(Created_Time,'DD/MM/YYYY hh:mm') as Created_Time,

timestamp#(Resolved_time,'DD/MM/YYYY hh:mm') as Resolved_time

inline [
Created_Time,Resolved_time
23/07/2018 19:30,24/07/2018 10:30
02/09/2018 13:11,-
01/11/2018 12:45,01/11/2018 3:45
];

clipboard_image_0.png

Thanks and regards,

Arthur Fong

View solution in original post

2 Replies
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

Add in timestamp formatting in your load script, possibly QV reading the timestamp as string:

LOAD *,
Resolved_time-Created_Time as [Time in Days & Hours],
if(isnull(Resolved_time)or len(Resolved_time)<=1,'Open','Closed') as Status;
load
timestamp#(Created_Time,'DD/MM/YYYY hh:mm') as Created_Time,

timestamp#(Resolved_time,'DD/MM/YYYY hh:mm') as Resolved_time

inline [
Created_Time,Resolved_time
23/07/2018 19:30,24/07/2018 10:30
02/09/2018 13:11,-
01/11/2018 12:45,01/11/2018 3:45
];

clipboard_image_0.png

Thanks and regards,

Arthur Fong

Brett_Bleess
Former Employee
Former Employee

Did Arthur's post help you get what you needed, or are you still working upon things?  If the prior, be sure to use the Accept as Solution button on the post that helped you to give credit to the poster and let others know that was the correct solution.  If you are still working on things, let us know where they stand, so we can try to come up with some other ideas.  

Here is a Design Blog link that may be helpful as well:

https://community.qlik.com/t5/Qlik-Design-Blog/Why-don-t-my-dates-work/ba-p/1465849

https://community.qlik.com/t5/Qlik-Design-Blog/The-Date-Function/ba-p/1463157

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.