Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hallo Zusammen,
ich hoffe es kann mir jemand weiter helfen, wie ich diese Selektion festlegen kann, dass ich den richtigen Preis bekomme.
Und zwar benötige ich den korrekten Preis, je nachdem welche Menge und welches Datum dazu gehört.
Um es besser zu verstehen folgende Tabelle, in welcher die Preise festgelegt sind:
Teil | Gültig_ab | StaffelMenge | Preis |
---|---|---|---|
A | 01.07.2018 | 0 | 119 |
A | 01.07.2018 | 10 | 98 |
A | 01.07.2018 | 50 | 49 |
A | 01.07.2018 | 100 | 27 |
A | 01.07.2018 | 250 | 14 |
A | 01.09.2018 | 0 | 115 |
A | 01.09.2018 | 10 | 95 |
A | 01.09.2018 | 50 | 45 |
A | 01.09.2018 | 100 | 25 |
A | 01.09.2018 | 250 | 12 |
Diese Tabelle listet auf welches Teil, wann und mit welcher menge was für einen Preis hat, also welche ich vorgegeben habe und an Hand dieser sollen die TeilePreise pro Kunde ermittelt werden.
Denn bei folgendem Teil A, welches einmal zum 2.8 mit 40 Stück geliefert wird, muss der preis für eine Menge ab 10 stück verwendet werden, welcher am dem 1.7 gilt, da die anderen entweder eine andere Staffelmenge haben oder erst ab dem 1.9 gültig sind.
Teil | Datum | Menge | TeilePreis |
---|---|---|---|
A | 02.08.2018 | 40 | 98 |
A | 10.09.2018 | 70 | 45 |
Ich habe dafür folgende Formel überlegt:
=max({< Gueltig_ab ={"<=$(=Datum)"}, StaffelMenge = {"<=$(=Menge)"}>} Preis)
allerdings klappt das mit dem Gueltig_ab leider nur wenn ich das aktuelle Datum und das Gültig_ab selektiert habe, was aber nicht gewünscht ist, es soll einfach den passenden Satz aus der Tabelle nehmen und den Preis anzeigen, auch wenn kein Datum ausgewählt ist.
Und bei der Menge, habe ich jetzt auch nur eine halbe Lösung mit dem das sie größer sein muss wie die Staffelmenge, und davon dann der größte Preis genommen wird, da Gehöft wird das um so mehr bestellt wird um so teurer, dieses will ich aber auch nicht so auf gut glück, sondern es soll genau den preis nehmen, welcher die menge größer der staffelmenge ist und aber auch kleiner der nächsten staffelmenge.
Wer hat dafür eine Idee, wie dieses korrekt umgesetzt werden kann?
Vielen Dank schon mal und Grüße
Merry
So now I have found a completely different solution. With first, separately created table, in which add to each scale price the date to have a continuous daily price and this I am attached to the existing parts table.
Hi Merry,
I'd need to have some sort of intervals for your dates and StaffelMenge fields.
Something like this:
x:
load
Teil,
Date#(Gueltig_ab,'DD.MM.YYYY') as Gueltig_ab,
StaffelMenge_From,
StaffelMenge_To,
Preis,
Date#(Gueltig_ab2,'DD.MM.YYYY') as Gueltig_ab2;
load * Inline
[
Teil,Gueltig_ab,StaffelMenge_From,StaffelMenge_To,Preis,Gueltig_ab2
A,01.07.2018,0,10,119,01.09.2018
A,01.07.2018,10.01,50,98,01.09.2018
A,01.07.2018,50.01,100,49,01.09.2018
A,01.07.2018,100.01,250,27,01.09.2018
A,01.07.2018,250.01,999999,14,01.09.2018
A,01.09.2018,0,10,115,31.12.2018
A,01.09.2018,10.01,50,95,31.12.2018
A,01.09.2018,50.01,100,45,31.12.2018
A,01.09.2018,100.01,250,25,31.12.2018
A,01.09.2018,250.01,999999,12,31.12.2018
];
Data:
load
Teil,
Date#(Datum,'DD.MM.YYYY') as Datum,
Menge;
load * Inline
[
Teil,Datum,Menge
A,02.08.2018,40
A,10.09.2018,70
];
IntervalMatch(Datum)
left join (Data)
Load
Distinct
Gueltig_ab,
Gueltig_ab2
Resident x;
IntervalMatch(Menge,Gueltig_ab)
left join (Data)
Load
StaffelMenge_From,
StaffelMenge_To,
Gueltig_ab
Resident x;
left join (Data)
Load
StaffelMenge_From,
StaffelMenge_To,
Gueltig_ab,
Gueltig_ab2,
Preis
Resident x;
drop table x;
The intervalmatch will get for which dates it belongs to (01.07.2018) and the StaffelMenge range, which I created by getting the value of the next line, so it would be as an example from
0 -> 10
10.01 -> 50
50.01 -> 100
and so forth.
Thanks for the answer.
Yes that example from you is right.
And if i unterstood it right, is there no way, to solve it in the diagram with a formel?
So I have to make it with the intervallmatch? That I have short thinking as well, but I have a lot dates for each part, and each part have more staffeln, so that will be a lot of dates for many staffeln.
Set analyis is evaluated only once per chart, so it wouldn't have the ability to check all the possible variations you have on your data, that's why when you select the proper filters it works.
For creating the date interval, you can do the following instead of inputing it manually.
Something like:
x:
load
Teil,
Date#(Gueltig_ab,'DD.MM.YYYY') as Gueltig_ab,
StaffelMenge,
Preis;
load * Inline
[
Teil,Gueltig_ab,StaffelMenge,Preis
A,01.07.2018,0,119
A,01.07.2018,50,98
A,01.07.2018,100,49
A,01.07.2018,250,27
A,01.07.2018,999999,14
A,01.09.2018,0,115
A,01.09.2018,50,95
A,01.09.2018,100,45
A,01.09.2018,250,25
A,01.09.2018,999999,100
A,01.12.2018,100,55555
];
_tmpData:
Load
Distinct Teil,
Gueltig_ab
Resident x
order by Teil,Gueltig_ab;
dates:
Load
Teil,
Gueltig_ab,
peek(Gueltig_ab) as New_Gueltig_ab
Resident _tmpData;
drop table _tmpData;
left join (dates)
Load
New_Gueltig_ab as Gueltig_ab,
Gueltig_ab as Neues_Gueltig_ab
Resident dates;
_tmpData:
Load
Teil,
Gueltig_ab,
if (isNull(Neues_Gueltig_ab),Date(YearEnd(Today()),'DD.MM.YYYY'),Neues_Gueltig_ab) as Neues_Gueltig_ab
Resident dates;
drop tables dates;
left join ( x)
Load
Teil,
Gueltig_ab,
Neues_Gueltig_ab
Resident _tmpData;
drop Table _tmpData;
If you create a proper association between the Datum and the Gültig_ab fields by creating a link table (Named SP in my example) you can use the following expression:
FirstSortedValue( {<UID_SP={"=Menge-StaffelMenge>=0"}>} Preis, Menge-StaffelMenge )
UID_SP is a unique row ID that has to be calculated in the StaffelPreis table.
My propsed solution which I posted above calculates all dates but can be optimized to only consider dates that are valid links unless you need the entire date range. Then the load script would look like this:
STAFFELPREISE:
LOAD RowNo() AS UID_SP,AutoNumber(Teil&'|'&Gültig_ab) AS %TG, * INLINE [
Teil Gültig_ab StaffelMenge Preis
A 01.07.2018 0 119
A 01.07.2018 10 98
A 01.07.2018 50 49
A 01.07.2018 100 27
A 01.07.2018 250 14
A 01.09.2018 0 115
A 01.09.2018 10 95
A 01.09.2018 50 45
A 01.09.2018 100 25
A 01.09.2018 240 12
A 30.09.2018
] (delimiter is spaces);
KUNDE:
LOAD AutoNumber(Teil_&'|'&Datum) AS %TD,* INLINE [
Teil_, Datum, Menge
A, 02.08.2018, 40
A, 10.09.2018, 70
];
SP:
LOAD
%TD, %TG
WHERE
Exists(%TD);
LOAD
AutoNumber(Teil&'|'&Date(Gültig_ab+IterNo()-1)) AS %TD,
AutoNumber(Teil&'|'&Gültig_ab) AS %TG
WHILE
Date(Gültig_ab+IterNo()-1)<Gültig_zum;
LOAD
Teil,
Previous(Gültig_ab) AS Gültig_ab,
Gültig_ab AS Gültig_zum
WHERE
RecNo()>1;
LOAD Teil,Gültig_ab , Sum(0) AS Dummy RESIDENT STAFFELPREISE GROUP BY Teil,Gültig_ab;
That looking good.
If i have the field for "Gültig_ab", I can take that instad of "Privious(Gültig_ab)" or?
if i take that, can I write instatt of "peek(Gueltig_ab)" Gueltig_bis, if I have that field as well?
And how I do with the New_Gueltig_ab, did I need that as well? or is it the same like Neues_Gueltig_ab and my Gueltig_bis?
I am not sure that I understand your question. I have provided a working "demo" app and I am not sure what kind of change you need to implement in your solution...
In my table I have not only the valide from, i have as well the date of Expiry, so I Thing the calculate for that i don't Need or?
and instead of the calculation (Privious(Gültig_ab)) i can take my field with date of Expiry ?