I got stuck under a peculiar situation when I am trying create a dashboard. I have the following data sample with me (also attached in the excel file with c. 200K rows data). Now, the "ROLLING SYSTEM" data is the primary key here and the "Time" field is derived from 'ROLLING SYSTEM' field. One catch here is that time is not consistent with 5 minutes interval (although it is there for most of the times, but I can't make any exceptions as every day new data will be appended).
What I would like to have in the output is average demand for every hourly period against the ending hour time period.
i.e. against 01:00:00 the average demand should be average of 'Demand' field data for time period >= 00:00:00 and <01:00:00;
against 02:00:00 the average demand should be average of 'Demand' field data for time period >= 01:00:00 and <02:00:00; and so on. Something like this:
|Time Period||Average Demand|
It would be great if anyone can help me out with this. thanks a ton in advance. best regards, Anand
You could try using the hour() function. hour ‒ QlikView
Either you create a calculated dimension in the object or a new field in your dimensiontabel, and add 1 to the hour value so 00:05:00 and 00:55:00 becomes "1" etc.
An alternative solution and if you want a better label, you could try to round your timestamp by the following solution based on hour and string manipulation using:
LOAD * INLINE [
time(hour([Time]) +1 & ':00:' & '00') as RoundTime
Else look into the following thread for other ways to round a timestamp to whole hours.
Many thanks Varun for your reply. I guess I missed one point here. The average demand needs to be calculated for every hour for each time period for all the dates given (dated are given in the first column of attached excel 'ROLLING SYSTEM' field, where the first eight characters gives us date in 'YYYYMMDD' format. The output should be something like:
|ROLLING SYSTEM||Time Period||Average Demand|
Many thanks in advance for your help here. Best regards, Anand
may be this
LOAD [ROLLING SYSTEM],
date(date#(left([ROLLING SYSTEM],8),'YYYYMMDD'),'YYYYMMDD') as Date,
time#(Time,'hh:mm:ss') as Time,
[Final Demand Data.xlsx]
(ooxml, embedded labels, table is Sheet1);
Date&'000000' as [ROLLING SYSTEM],
Time(Time + maketime(1,0,0),'hh')&':00:00' as [Time Period],
DROP Table Data;