Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Avoid to expand data to work with dates

Good morning, I am looking for a piece of script about “master calendars” or a similar solution to the following problem:

My BBDD data source generates rows or records like these  (date format dd/mm/yy):

HOTELMMCDOTOTTOOIDCTOFIPEFFPETHABASE
1ALEALEMANIAAIMTHOMAS COOK AG (AIM)8213AIMTULS1201/05/201208/05/2012HA75
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA77

Where the Price (BASE) is 75 y 77 for the periods included between FIPE (Begining Period Date) and FFPE (Ending Period Date) respectively, that means, for the first record or row the valid price (BASE) is 75 during 8 days and for the second record the valid price is 77 during 20 days.

Summarizing, in order to analyze Price averages for  differents periods etc the only way I found was to join a new column called FECHA (DATE) and transformate the original BBDD table in this other:

HOTELMMCDOTOTTOOIDCTOFIPEFFPETHABASEFECHA
1ALEALEMANIAAIMTHOMAS COOK AG (AIM)8213AIMTULS1201/05/201208/05/2012HA7501/01/2012
1ALEALEMANIAAIMTHOMAS COOK AG (AIM)8213AIMTULS1201/05/201208/05/2012HA7502/01/2012
1ALEALEMANIAAIMTHOMAS COOK AG (AIM)8213AIMTULS1201/05/201208/05/2012HA7503/01/2012
1ALEALEMANIAAIMTHOMAS COOK AG (AIM)8213AIMTULS1201/05/201208/05/2012HA7504/01/2012
1ALEALEMANIAAIMTHOMAS COOK AG (AIM)8213AIMTULS1201/05/201208/05/2012HA7505/01/2012
1ALEALEMANIAAIMTHOMAS COOK AG (AIM)8213AIMTULS1201/05/201208/05/2012HA7506/01/2012
1ALEALEMANIAAIMTHOMAS COOK AG (AIM)8213AIMTULS1201/05/201208/05/2012HA7507/01/2012
1ALEALEMANIAAIMTHOMAS COOK AG (AIM)8213AIMTULS1201/05/201208/05/2012HA7508/01/2012
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7701/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7702/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7703/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7704/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7705/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7706/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7707/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7708/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7709/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7710/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7711/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7712/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7713/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7714/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7715/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7716/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7717/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7718/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7719/11/2011
1ALEALEMANIABUCHERTHOMAS COOK AG (BUC)3614BUCHERTULW1101/11/201120/11/2011HA7720/11/2011

This way I can deal with dates, data and formulas with total flexibility thanks to the new field FECHA (DATE), but is unbearable for access or excel.

Could please anyone suggest me a solution or advice in QV script code to work with dates without having to expand the BBDD data source?

Thank you

13 Replies
Not applicable
Author

Perfect, now I think I have to create a master calendar linked to FECHA in order to compare months of different years an so on.

Thank you very much.

Not applicable
Author

Please one last question,

I made the master calendar and I see that the first date of 'FECHA' it takes is not the very first date of all, I assume it is because I am using 'peek' without having ordering BBDD by FECHA.

I tried to put ...FROM....ORDER BY FECHA but at that line of the script 'FECHA' do not exists yet so it gives me script error.

How could I order by 'FECHA' to make the mastercalendar correctly?

Thanks

hic
Former Employee
Former Employee

you use the following lines to find the first and last date:

let varmindate = num(Peek('FECHA',0,'BBDD'));

let varmaxdate = num(Peek('FECHA',-1,'BBDD'));

I suggest you replace these by

MinMaxDate:

Load Min(FECHA) as MinFECHA, Max(FECHA) as MaxFECHA resident BBDD;

let varmindate = num(Peek('MinFECHA',-1,'MinMaxDate'));

let varmaxdate = num(Peek('MaxFECHA ',-1,'MinMaxDate'));

Drop Table MinMaxDate;

HIC

Not applicable
Author

It seems there is something wrong with 'varmaxdate', it takes value <NULL> whereas varmindate is 40180 which is right.