Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello All!
These are great bits of coding. However, I'd like to caution that the use of now() in a chart expression is generally a bad idea from a performance point of view. It generates a fairly constant CPU activity.
-Rob
I'm going to guess that now(0), the time of the load, would be fine in this case. Since we're looking at near real time data, I assume this file is being reloaded very frequently, such as every ten minutes. If the data is 9 minutes stale, I would think when you ask for something in the past two hours, you'd be fine with getting something in the past two hours and 9 minutes, and nothing for the past 9 minutes.
Oleg, feel free to post on Wiki. Frankly, I didn't think it's something special. If I have time and don't forget, I'll try to describe a really complex case.
Rob, you're right abot the now() function. I thought of my example more like the idea rather than ready-to-use solution.
John, you're correct about the now(0). I never thought about it. In any case it's not fair to expect theat QV application provides the real-time data.
Hi Everyone,
Thanks to Michael, John, Oleg for you inputs, last few questions to finish this off...
1. I also like Michael's Timefilter.qvw, but performance will be important to me (new thread next week on that) so i tryed the set analysis example and replaced the
if(Time>=now()-Input/24,1)
with
sum({<Time={">=$(=timestamp(now()-Input/24))"}>} 1)
but i don't get any results, I'm still on a learning curve so not sure where the problem is on that statement.
2. I can get my data to filter (with the if statement) to a 2/4/8 hour period as needed,
But i also have month, date, hour, min etc list box fields on screen which are used to show&select times and dates.
Is it possible to have these list box's highlight to reflect I'm viewing a particular hour period?
So if the time/date was 11/5/2009 12:33:00 and i was viewing a 2 hour period, I'd like my year/month/day highlight,
the hours 10,11,12 and all the mins highlight if possible.
Thanks,
Peter.
Peter,
to highlight the selected period in the list boxes, you have to use "Selection" functionality and not "Set Analysis". Michael's example with the calculated List Box is the best example of how to use it. Repeating Rob's advise, - using now() might negatively affect your performance, since it triggers constant "action" by the timer. You should think of replacing now() with some other variables, or at least use now(0) which will give you the time of the reload.
cheers,
Oleg
Hi Oleg,
Thanks for the input, i'm using the reload time as a fixed point for my hour periods.
Very last question, when i select a time 'window' , i want everything from x hours ago to present.
The ceil(((now(0)-Time)*24) gives me only a 1 hour time frame starting x hours ago.
Thanks,
Peter.
Peter,
If you are using reload time as the fixed time, you may want to pre calculate in the script instead of in the charts. Attached is a modification of a QV Cookbook example that lets you assign Times to groups like "1 Hour" or "Today".
-Rob
Thanks to everyone who's helped out on this thread!
The example Rob posted worked perfectly for my application, and the other examples have tought me some new things too.
Thanks,
Peter.