Midavalo
New Member
- Joined
- Apr 23, 2007
- Messages
- 7
- Office Version
- 365
- Platform
- Windows
In my data I have a couple of columns that are added to regularly (Val1 and Val2) from which I need to subtract a total (Calc) into two new columns (Net_Val1 and Net_Val2). I need to subtract my value in Calc proportionately between Val1 and Val2, however there are some conditions that need to be met. I'm calculating the value to subtract into Val1_C and Val2_C.
although this also falls over a bit if Val1 is a negative.
I'd appreciate a point in the right direction please. Here is my sample data, with what I expect to see in Val1_C and Val2_C. I've struggled to put this all into words, so hopefully it makes sense enough.
- If Val2 is 0 (or less than 0) the full amount is subtracted from Val1 (see rows 2-4)
- I can only reduce Val2 by a half maximum. Anything remaining is subtracted from Val1 (see rows 5, 7, 8)
- Because of #2 above, Val2 can never be reduced to negative. Val1 can be negative.
- If both Val1 and Val2 are positive, and none of the above apply, then proportion the value in Calc between Val1 and Val2, eg
Excel Formula:
=[@Calc]/SUM([@[Val1]:[Val2]])*[@Val1]
Excel Formula:
=IFS([@Val2]<=0,[@Calc],TRUE,[@Calc]/SUM([@[Val1]:[Val2]])*[@Val1])
I'd appreciate a point in the right direction please. Here is my sample data, with what I expect to see in Val1_C and Val2_C. I've struggled to put this all into words, so hopefully it makes sense enough.
MyCalcTesting.xlsx | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | Val1 | Val2 | Val1_C | Val2_C | Calc | Net_Val1 | Net_Val2 | ||
2 | 475 | 0 | 1000 | 1000 | -525 | 0 | |||
3 | 1450 | 0 | 1000 | 1000 | 450 | 0 | |||
4 | -2450 | 0 | 1000 | 1000 | -3450 | 0 | |||
5 | -1500 | 600 | 700 | 300 | 1000 | -2200 | 300 | ||
6 | 3950 | 210 | 949.52 | 50.48 | 1000 | 3000.48 | 159.52 | ||
7 | -100 | 100 | 900 | 50 | 1000 | -1000 | 50 | ||
8 | 225 | 1120 | 440 | 560 | 1000 | -215 | 560 | ||
9 | 375 | 4050 | 84.75 | 915.25 | 1000 | 290.25 | 3134.75 | ||
Sheet2 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
E2:E9 | E2 | =1000 |
F2:F9 | F2 | =[@Val1]-[@[Val1_C]] |
G2:G9 | G2 | =[@Val2]-[@[Val2_C]] |