Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Applicable88
Creator III
Creator III

Interval function and condition

Hello,

I have a machine which can go charging automatically.

For the Action=charging I want to know the duration of it.

Around 2 PM o'clock it will be shutdown. So if the charging of the machine starts around that time it stays at the charging station overnight. But that duration is not representing the average duration its on "charging"

So I instead use the interval of the Action Timestamps where the charging starts and finishes at the same shift. 

I wrote something like this:

=if((date(FinishedTime))=(date(StartedTime))),Interval(FinishedTime-StartedTime,'hh:mm:ss'))

But for time in every line of the table I just getting : 00:00:00

I also tried to use the num() to translate the date where the date in numeric is the same, but I would get the same results. 

I hope someone has an idea .

Thanks in advance. 

Best.

5 Replies
Brett_Bleess
Former Employee
Former Employee

You may need to use the following instead depending upon whether things are strings or not is all I can figure at the moment:

https://help.qlik.com/en-US/sense/September2020/Subsystems/Hub/Content/Sense_Hub/Scripting/Interpret...

Here is the help for the numeric format you have been trying to use:

https://help.qlik.com/en-US/sense/September2020/Subsystems/Hub/Content/Sense_Hub/Scripting/Formattin...

Apologies if I am way off here, but hoping this may be the issue.

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.
Applicable88
Creator III
Creator III
Author

Hello @Brett_Bleess ,

thank you for your reply.  But the problem lies in the condition that both days are the same. The interval is already correctly interpreted via Load Script. 

I hope someone else has an idea. 

Brett_Bleess
Former Employee
Former Employee

I may be way off here, but I noticed you are calling date function in your expression, should that not potentially be time or timestamp in this case?  Sorry if I am still off on things.

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.
Applicable88
Creator III
Creator III
Author

Hello @Brett_Bleess ,

yes of course . As far I know I want to tell the If -Statement to only show me the duration between start and finished time in case the the starting and finishing time are still at the same day. 

If the duration is calculated between two days....this is something I want to exclude. With date() function 

I actually just extract the dates of bowth fieldnames and ask if they are the same. If yes, please return me the duration. 

Hope explained better this time. 

Brett_Bleess
Former Employee
Former Employee

@Applicable88  sorry I am not more help and hopefully the additional info will help someone with better dev skills than me help you sort things out.

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.