Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Filling in Date Ranges

I am building a dashboard to calculate MPG for trucks.

The data comes in bursts and not linear in nature.

I have attached the QVD file and need to manipulate it within the load script.

fields include MPG, miles, consumed total, drive time and Driver code. As well as a startdate and an EndDate field.

What i would like to do is make the data continuous.

what i have now:

Start Date - 10/19/09

EndDate- 10/26/09

MPG- 9.526

Driver- PATAN

WHAT I NEED (from above):

date- 10/19/09 MPG- 9.526 Driver-PATAN

date- 10/20/09 MPG- 9.526 Driver-PATAN

date- 10/21/09 MPG- 9.526 Driver-PATAN.... Until 10/26/09

Then @ 10/27/09 When a new period starts:

10/27/09 MPG-10.5 Driver-PATAN,.....

Basically i just need to fill in space in between ranges with the same info for every day.

What do you suggest?

Here is a sample of the QVD

%UnitDateMPGUnitNoMPGDriverCodeMPGStartDateMPGEndDateMPGWkStartMPGWkEndMPGOverRevTimeMPGTripCountMPGTotalDistanceMPGDrivingTimeMPGEngineTimeMPGPTOFuelConsumedMPGFuelConsumedMPGParkedIdleTimeMPGShortIdleMPGInterTripIdleMPGMovingTimeMPGIdleFuelGallons
REEF VAN 639987REEF VAN 6MORMAR5/25/20096/23/20096/22/20096/29/200912443202032131433619
REEF VAN 940004REEF VAN 96142852885/16/20097/10/20097/6/20097/13/2009122160214237021015152042
TEST CART39948TEST CARTWIGGCH4/16/20095/15/20095/11/20095/18/20099916155917841821026001212172314
104003210BURERD8/5/20098/7/20098/3/20098/10/20090654370288407328517965420
20039960200ENGE5/20/20095/27/20095/25/20096/1/2009312362702740320002531
20039961200ENGE5/27/20095/28/20095/25/20096/1/200974424452476049018184383
20039979200ENGE5/28/20096/15/20096/15/20096/22/200910464969169501010006711
20039987200ENGE6/15/20096/23/20096/22/20096/29/200913773580182001070007627
20039993200ENGE6/23/20096/29/20096/29/20097/6/20098236399742124303057425454409819
20040007200ENGE7/9/20097/13/20097/13/20097/20/200954152322233427460363415400230834
20040009200ENGE7/13/20097/15/20097/13/20097/20/20091811325529807048414328243941
20040022200ENGE7/15/20097/28/20097/27/20098/3/200952222402247535260339122771054241198
20040023200ENGE7/28/20097/29/20097/27/20098/3/200995649693114009262744466446
20040036200ENGE7/29/20098/11/20098/10/20098/17/20095636567267460104021216913
20040045200ENGE8/11/20098/20/20098/17/20098/24/2009651913431615187302294107260150934
20040049200*GIXX8/20/20098/24/20098/24/20098/31/2009342599610305066772


3 Replies
disqr_rm
Partner - Specialist III
Partner - Specialist III

Here you go:

DriveRecords:
LOAD * INLINE [
StartDate, EndDate, MPG, Driver
10/19/2009, 10/26/2009, 9.526, PATAN
10/22/2009, 11/26/2009, 2.126, PATAN1
];

AllDates:
LOAD DISTINCT date#(StartDate) as Date
RESIDENT DriveRecords;
LOAD DISTINCT date#(EndDate) as Date
RESIDENT DriveRecords;

MinMax:
Load min(Date) as MinDate,
max(Date) as MaxDate
resident AllDates
group by 1;

Let vMinDate = peek('MinDate');
Let vMaxDate = peek('MaxDate');
Let vDays = vMaxDate - vMinDate + 1;

drop tables AllDates, MinMax;

FilldDates:
Load date($(vMinDate) + recno() - 1) as Date
AUTOGENERATE $(vDays);

Left join (DriveRecords)
IntervalMatch (Date)
LOAD StartDate, EndDate
RESIDENT DriveRecords;

drop table FilldDates;

Not applicable
Author

Hi,

nice Skript!

A little suggestion. If you dont drop the table FilldDates you can also see dates where no driver is set in the table DriveRecords. This happens when the intervals StartDate - EndDate doesn't overlap or fit together.

Eg:

DriveRecords:
LOAD * INLINE [
StartDate, EndDate, MPG, Driver
10/19/2009, 10/26/2009, 9.526, PATAN
10/28/2009, 11/26/2009, 2.126, PATAN1
];



Not applicable
Author

It worked.

Thanks a bunch.

The only issue is my computer crashes if i pull in more than 10 days worth of data. is there a less memory intensive why to accomplish this?

if not maybe i will just have to run reloads in the production server while i am still developing it on my desktop.

any suggestions would be welcome.