I have a maths issue for a little VFP project I have on the go, it is in VFP but it's the math I am struggling with, please forgive if I am bending the rules a smidge.
I have a record where there are four fields which should add up to a target, so A+B+C+D = Target.
I have a form which has the four fields as data entry boxes and the target is displayed.
The target can change - it is really the product of a long complex process, not just A+B+C+D - when it changes
the user is alerted and pops up the form and decides how the target should be split across the four fields.
Simple enough, the user has complete discretion how the target is split. I provide buttons for each of the fields, with All (all target in A for example B,C & D set to zero),
Balance (the difference between the sum of the other fields and the target) and Nil, which zeros out the field.
The user wants a Pro Rata button, so his previous decision is used as the basis for the current situation.
i.e. if the previous target was 200 and he split it equally in four parts A,B,C & D would be 50 each, the new target is now 300 so
the Pro Rata button would work out each 'contribution' to the original target and change A,B,C & D to 75.
Works a treat - except where the split involves a negative in one of the fields.
In the above if the target was 200 and the original split 100,100,100 & -100 I think the Pro Rata split for a 300 target should be
150,150,150,-150.
But what about an original split to a zero target such as 100,-100,100 & -100? I don't think the Pro Rata split for a 300 target can be made.
Any thoughts? Hide the Pro Rata button for zero sum situations?
Regards
Griff
Keep [Smile]ing
I have a record where there are four fields which should add up to a target, so A+B+C+D = Target.
I have a form which has the four fields as data entry boxes and the target is displayed.
The target can change - it is really the product of a long complex process, not just A+B+C+D - when it changes
the user is alerted and pops up the form and decides how the target should be split across the four fields.
Simple enough, the user has complete discretion how the target is split. I provide buttons for each of the fields, with All (all target in A for example B,C & D set to zero),
Balance (the difference between the sum of the other fields and the target) and Nil, which zeros out the field.
The user wants a Pro Rata button, so his previous decision is used as the basis for the current situation.
i.e. if the previous target was 200 and he split it equally in four parts A,B,C & D would be 50 each, the new target is now 300 so
the Pro Rata button would work out each 'contribution' to the original target and change A,B,C & D to 75.
Works a treat - except where the split involves a negative in one of the fields.
In the above if the target was 200 and the original split 100,100,100 & -100 I think the Pro Rata split for a 300 target should be
150,150,150,-150.
But what about an original split to a zero target such as 100,-100,100 & -100? I don't think the Pro Rata split for a 300 target can be made.
Any thoughts? Hide the Pro Rata button for zero sum situations?
Regards
Griff
Keep [Smile]ing
There are 10 kinds of people in the world, those who understand binary and those who don't.
I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.