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: 
Not applicable

Interval

Hi Experts,

Can you please correct my equation. I am not getting how to apply flag in interval function. Since i want to take the difference b/w two timestamps with diffrent flags.

interval(if(Flag='no',Timestamp(min(Datetime,2)))-if(Flag='no',Timestamp(min(Datetime,2)))) as Difference

Thanks

9 Replies
Not applicable
Author

I think it looks ok. What happends? You have the same flag in both times btw.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

I think your expression is incorrect as it will only return a null (if flag <> 'no') or a zero. What are you trying to do in the expression?

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi ,

The two flags are different. Sorry earlier it was a mistake.

interval(if(Flag='no',Timestamp(min(Datetime,2)))-if(Flag='yes',Timestamp(min(Datetime,2))))) as Difference

Now after loading i am getting invalid syntax error. But looks ok in script. That means no red lines visible.

tresesco
MVP
MVP

Hi,

It seems that your logic is itself not very logical. One record can have one flag 'yes' or 'no'. Therefore you can't get difference between them for a single record (or to be precise, the difference is always going to be the one the Datetime field itself because the other one is always ZERO ...if one is true then the other one is false).

Not applicable
Author

Well, I assumed that he used a Group by. Otherwise it doesnt make any sense.


Try this

interval(Timestamp(min(if(Flag='no',Datetime),2))-Timestamp(min(if(Flag='yes',Datetime),2))) as Difference


Not applicable
Author

EngineerWorkOrderFlagDatetime
Ganesh100no01/01/2013 12:10
Ganesh100no02/01/2013 12:20
Ganesh100yes03/01/2013 12:40
Ganesh100yes04/01/2013 13:10
Ganesh100no05/01/2013 14:30
Ganesh100no06/01/2013 12:10
Ganesh100yes07/01/2013 12:10
Ganesh100yes08/01/2013 12:10
Ganesh100yes09/01/2013 12:10
Ganesh100yes10/01/2013 12:10

Hi,

I want to take the difference b/w 06/01/2013 12:10 and 04/01/2013 13:10

In this scenaro i have used interval function...Let me know if any more info needed for query.

Not applicable
Author

Hi,

You are right I am using group by here.

Can you please tell me that how to take difference b/w below.

Whatever u given answer that is correct. But I am looking something else like below bold labelled difference.

Ganesh100no01/01/2013 12:10
Ganesh100yes02/01/2013 12:20
Ganesh100yes03/01/2013 12:40
Ganesh100yes04/01/2013 13:10
Ganesh100no05/01/2013 14:30
Ganesh100no06/01/2013 12:10
Ganesh100yes07/01/2013 12:10
Ganesh100yes08/01/2013 12:10
Ganesh100yes09/01/2013 12:10
Ganesh100yes10/01/2013 12:10

07/01/2013 12:10 - 05/01/2013 14:30

Not applicable
Author

Ok, but what is your logic? I mean why are you comparing exactly that two dates? You have to tell Qlikview which dates you are comparing.

Not applicable
Author

I am implenting the same scenario in my assignment. There are different field names are there in real assignments. Here I did data mockup and calculating accordingly as I cant share business data or field.

In qlikview I can be able to take the diffrence b/w two dates withing same field with first minimum. But not on full extent. I mean to say , as currently I want to take the difference b/w (date)yes after no and (date)no after yes. This one is really difficult for me. So need Community help.