Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
takama13
Contributor II
Contributor II

Intervalmatch to correct values

Hi all,

My database is a set of 2 Excel files.

Some fields are the same (and used to link the 2 tables), some fields are different.

In each table, I have a field with a date of events.

But some data (Service Code) are wrong and I would like to correct them based on an Excel file I created with range dates.

Here below are my tables :

Table1 :  

Service CodeDateEventShould be
MAN01/06/2016Event1MAGE
MAN01/05/2018Event2MTS
COL01/06/2016Event3COLU
COL01/06/2018Event4CJS
VES01/01/2016Event5VESP
VES01/07/2018Event6VESP
MTS01/06/2016Event7MTS
MTS01/06/2018Event8CTPS

Table2 :  

Service CodeDateEventBShould be
MAN01/06/2016Event1MAGE
MAN01/05/2018Event2MTS
COL01/06/2016Event3COLU
COL01/06/2018Event4CJS
VES01/01/2016Event5VESP
VES01/07/2018Event6VESP
MTS01/06/2016Event7MTS
MTS01/06/2018Event8CTPS
VIC01/02/2017Event9VIC

Service Code correction:    

Service CodeFromToNew Service Code
MAN01/01/201501/04/2017MAGE
MAN02/04/201705/05/2018MTS
COL01/01/201504/04/2017COLU
COL05/04/201701/01/2019CJS
VES01/01/201501/01/2019VESP
MTS26/04/201801/01/2019CTPS

Here is the code I use to try and correct the tables :

Table1:

LOAD

     [Service Code],

     Date,

     Event,

     [Should be]

FROM

(ooxml, embedded labels, table is Feuil1);

Table2:

LOAD

     [Service Code],

     Date,

     EventB,

     [Should be] as [Should be 2]

FROM

(ooxml, embedded labels, table is Feuil1);

'Service Code correction':

LOAD

     [Service Code],

     From,

     To,

     [New Service Code]

FROM

(ooxml, embedded labels, table is Feuil1);

Inner Join ('Table1')

IntervalMatch ([Date],[Service Code])

LOAD [From], [To], [Service Code] Resident 'Service Code correction';

Right Join('Table1')

LOAD * Resident 'Service Code correction';

Inner Join ('Table2')

IntervalMatch ([Date],[Service Code])

LOAD [From], [To], [Service Code] Resident 'Service Code correction';

Left Join('Table2')

LOAD * Resident 'Service Code correction';

DROP Table 'Service Code correction';

DROP Field [From];

DROP Field [To];

The result is correct unless the fact that the lines with Service Code not present in 'Service Code correction' are removed.

I would like to keep them.

What am I doing wrong ?

Result for Table2:

     

DateEventBService CodeShould be 2New Service Code
01/01/2016Event5VESVESPVESP
01/06/2016Event1MANMAGEMAGE
01/06/2016Event3COLCOLUCOLU
01/05/2018Event2MANMTSMTS
01/06/2018Event4COLCJSCJS
01/06/2018Event8MTSCTPSCTPS
01/07/2018Event6VESVESPVESP

We can notice that the line with Service Code "VIC" disappeared. I would like to keep this line with 'New Service Code' column empty.

Thanks

12 Replies
takama13
Contributor II
Contributor II
Author

Here are the files.

Gysbert_Wassenaar

Looks like a bug. No idea what's happening. As soon as I change the Date even a tiny bit like rounding it to a fraction of a second with round(Date,1/86400000) all is well.


talk is cheap, supply exceeds demand
takama13
Contributor II
Contributor II
Author

I will use this workaround until someone could explain this bug.

Thanks for your time.