Help: Maybe something impossible. Cross many values and many variables
Good afternoon. I'm trying to make something and I don't know if it is possible. I have a table, with customers, customer category, Cust. Cat. Discount, item, item category, Item Cat. Discount, sales quantity, real unit price, recommend unit price. Something like this:
Customer
Cust. Category
Cust.Cat.Disc
Item
Item Category
Item Cat. Disc
Quantity
Real Price
Recommend Price
Cust1
Big
15%
Item1
Food
80%
100
10
12
Cust2
Middle
10%
Item1
Food
80%
10
2
5
Cust3
Short
5%
Item2
Non Food
2%
80
14
20
Cust4
Short
5%
Item3
Other
100%
90
3
30
By other side, I have defined variables, one to each Cust. Cat. Discount, and one to each Item Category Discount. (I really have 30 variables of Customer discount and 25 variables of Item Discount. I mean that is too hard try to define all the combinations...
VarDisc_Big = 15%
VarDisc_Middle = 10%
VarDisc_Short = 5%
VarDisc_Food = 99%
VarDisc_NonFood = 99%
VarDisc_Other = 99%
Then, My graphics should work like:
I let the user to change the % of each variable and, for each line, I have to test which discount is lower, VarDisc_Of customer or Var_Disc of Item Cat. Then apply this discount to the recommended price.
I have tought to make a very big IF, comparing the value of each line and use the right variable, but is impossible.
I had tought too, if I name of the variable is the same that the possible value, and If I could match each value with the name of the value...... I don't know...I'm lost
IF CustCat is BIG and ItemCategory is FOOD AND VarDisc_Big > VarDiscFood then Apply VarDiscFood ELSE
IF CustCat is BIG and ItemCategory is FOOD AND VarDisc_Big <= VarDiscFood then Apply VarDisc_Big ELSE
IF CustCat is BIG and ItemCategory is NON_FOOD AND VarDisc_Big > VarDisc_NonFood then Apply VarDiscNonFood...