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

Intervall function with set expression AND additional condition

Hello,

I'm using a intervall function like this:

avg({$<Action={'charging'}, FinishedTime1=StartedTime1>}interval(FinishedTime-StartedTime,'hh:mm:ss'))

As you can see I want to return the average duration  (FinishedTime minus StartedTime), but only for the Action when its on 'charging' mode. 

And additional to that it has to be the data where when its finished was on the same day as where I started it. 

So I guess the two field names FinishedTime and StartedTime cannot be just put in an equation within the  setexpression? 

Thank you in advance.

Best. 

 

1 Solution

Accepted Solutions
Kushal_Chawda

@Applicable88  This is how set analysis works. If you want to check it line by line then you may need to go with if condition like below

avg({$<Action={'charging'}>}if(FinishedTime1=StartedTime1,interval(FinishedTime-StartedTime,'hh:mm:ss')))

 

View solution in original post

4 Replies
Kushal_Chawda

@Applicable88  try below

avg({$<Action={'charging'}, FinishedTime1={"=FinishedTime1=StartedTime1"}>}interval(FinishedTime-StartedTime,'hh:mm:ss'))

Applicable88
Creator III
Creator III
Author

Hi @Kushal_Chawda ,

thank you very much. 

Why the statement actually needs to be in double quotes? {"=FinishedTime1=StartedTime1"}

Since its already recognized as datefields, I wonder because shouldn't it search line by line automatically?

Best. 

Kushal_Chawda

@Applicable88  This is how set analysis works. If you want to check it line by line then you may need to go with if condition like below

avg({$<Action={'charging'}>}if(FinishedTime1=StartedTime1,interval(FinishedTime-StartedTime,'hh:mm:ss')))

 

Applicable88
Creator III
Creator III
Author

@Kushal_Chawda , good to know the alternative! I got the same results. I just needed floor() function for the two Time fields, than it works out as well. 

As I see it the way you wrote it as set expression and also as if-statement is searching line by line. Only if doing something with DSE would be different. 

Thank you so much.