Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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
MVP
MVP

Re: Limit on graph

'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.

8 Replies
Not applicable

Limit on graph

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

Limit on graph

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

Not applicable

Limit on graph

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

Limit on graph

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

Limit on graph

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

MVP
MVP

Re: Limit on graph

'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

Limit on graph

that was the entire problem it seems!

So this worked for me for everyones reference:

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

MVP
MVP

Limit on graph

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.

Community Browser