8 Replies Latest reply: Aug 4, 2011 2:40 PM by John Witherspoon RSS

    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.

        • 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))

          • Re: Limit on graph
            John Witherspoon

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


            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.

              • 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))

                  • Limit on graph
                    John Witherspoon

                    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.