Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Limit on graph

Hi All,

I am trying to limit the graph to show only certain times on the x-axis, but the formula doesnt seem to be working. this is what i am using:

=if(time(samptime) > '8:00:00 AM', time(samptime))

but QV is not recognizing it, and giving me all the times.

Thanks for your time in advance.

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

'8:00:00 AM' is a string literal.  It can't be meaningfully compared to a time value.  Here are some ways to get a comparable time value.

time#('8:00:00 AM','h:mm:ss TT')
maketime(8)
8/24

Edit: And looking more closely, you don't have a time field.  You have a timestamp field.  Using time() doesn't convert it into a time, it only DISPLAYS it as a time.  Frac(samptime) should work.

View solution in original post

8 Replies
Not applicable
Author

I am on personal so I can not open your sample gvw, but have you tried something like

=if(time(samptime) > '8:00:00 AM', YOURVALUEFIELD)

where YOURVALUEFIELD  is your expression?

I have something like this in mine to exclude invoices that are not related to sales orders. if(isnull(invoicemonthyear),0,sum(extprice) + sum(miscamt))

Not applicable
Author

where YOURVALUEFIELD is my expression? i didnt get that.. can you please explain..

Not applicable
Author

I am assuming that the dimension is set to Sample time correct? What field are you looking at for values on the graph?

In my example the value I was looking at was sum(extprice) + sum(miscamt).

Sorruy just re-read and I mis typed.

set YOURVALUEFIELD in that formula to the field that you are using for you values in the graph.

Paste this formula as the expression for the graph

Not applicable
Author

That's what im trying to do actually:

=if(time(samptime) > '8:00:00 AM', time(samptime))

So im checking a field called samtime and if its more than 8 AM, then i want all the times after that.

Not applicable
Author

but this isnt working for some reason, and its returning me all the times begn from 12 AM ..

johnw
Champion III
Champion III

'8:00:00 AM' is a string literal.  It can't be meaningfully compared to a time value.  Here are some ways to get a comparable time value.

time#('8:00:00 AM','h:mm:ss TT')
maketime(8)
8/24

Edit: And looking more closely, you don't have a time field.  You have a timestamp field.  Using time() doesn't convert it into a time, it only DISPLAYS it as a time.  Frac(samptime) should work.

Not applicable
Author

that was the entire problem it seems!

So this worked for me for everyones reference:

=if(frac(samptime) >= '6:00:00 AM' , time(samptime))

johnw
Champion III
Champion III

Huh!  I did not realize that QlikView would automatically convert a string literal into a time in that situation.  It looks like it MUST match the default time format set in the script, but as long as it does, it properly interprets it.  I just learned something new. 

I'd probably still recommend against it because you might, say, go and change your default time format, and forget to change all your string literals.  The approaches I used above are not sensitive to your defaults like that.  Still, interesting.