Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Liebe Community,
ich bin QV-Beginner und habe folgendes Problem:
Ich möchte Daten nachträglich datumsabhängige Informationen zuordnen.
Beispiel:
Die datumsbezogenen Verkäufe eines Artikel liegen vor.
dat_verkauf:
ArtNr | VerkaufDatum |
---|---|
1 | 31.12.2012 |
1 | 01.01.2013 |
1 | 02.01.2013 |
Die datumsabhängigen Preise des Artikels liegen ebenfalls vor.
sta_preise:
ArtNr | AbDatum | Preis |
---|---|---|
1 | 31.12.2012 | 10€ |
1 | 01.01.2013 | 20€ |
Wie kann ich den verkauften Artikeln, nun die zum Zeitpunkt des Verkaufs gültigen Preise zuordnen?
dat_verkauf:
ArtNr | VerkaufDatum | Preis |
---|---|---|
1 | 31.12.2012 | 10€ |
1 | 01.01.2013 | 20€ |
1 | 02.01.2013 | 20€ |
Hat hierzu jemand ein Code-Snippet in petto?
Vielen Dank im Voraus!
Dirk
Load Script:
Beispiel:
LOAD * INLINE [
ArtNr, VerkaufDatum
1, 31.12.2012
1, 01.01.2013
1, 02.01.2013
];
sta_preise_temp:
LOAD * INLINE [
ArtNr, AbDatum, Preis
1, 31.12.2012, 10€
1, 01.01.2013, 20€
];
sta_preise:
LOAD ArtNr, AbDatum as FromDate, if(ArtNr = previous(ArtNr), date(previous(AbDatum)-1), date(today())) as ToDate, Preis
RESIDENT sta_preise_temp
ORDER BY AbDatum DESC;
DROP TABLE sta_preise_temp;
Inner Join
IntervalMatch(VerkaufDatum,ArtNr)
LOAD FromDate, ToDate, ArtNr
RESIDENT sta_preise;
Example file also attached.
Sehe How to populate a sparsely populated field
Load Script:
Beispiel:
LOAD * INLINE [
ArtNr, VerkaufDatum
1, 31.12.2012
1, 01.01.2013
1, 02.01.2013
];
sta_preise_temp:
LOAD * INLINE [
ArtNr, AbDatum, Preis
1, 31.12.2012, 10€
1, 01.01.2013, 20€
];
sta_preise:
LOAD ArtNr, AbDatum as FromDate, if(ArtNr = previous(ArtNr), date(previous(AbDatum)-1), date(today())) as ToDate, Preis
RESIDENT sta_preise_temp
ORDER BY AbDatum DESC;
DROP TABLE sta_preise_temp;
Inner Join
IntervalMatch(VerkaufDatum,ArtNr)
LOAD FromDate, ToDate, ArtNr
RESIDENT sta_preise;
Example file also attached.
Vielen Dank!
Hi Nicole,
I have found a small bug in your scripts:
sta_preise:
LOAD ArtNr, AbDatum as FromDate, if(ArtNr = previous(ArtNr), date(previous(AbDatum)-1), date(today())) as ToDate, Preis
RESIDENT sta_preise_temp
ORDER BY ArtNr, AbDatum DESC;
Thank you again!
Kind regards
Dirk
Good catch! I missed that one.