still not getting the hang of the calc element...grrrrr

Racmitch

Member
I am again working with the calc element. I thought I had it figured out, but still getting the wrong number in the total when I do a % total.

The actual math is (numbers are just what I'm using as a sample) 100 -75 / 100 * 100 to equal 25%

now I have to add the fields from each equation to get those totals. example to get the first 100 I am adding fields 1,2,3,4 to = 100, then adding the 3 fields to get the 75 that I am subtracting from the initial 100, then adding the field to give me the divisible number of 100 and then finally multiplying by 100. my formula looks like this:

Adding for the 100
return ((float)'{monthly_expenses___expamount_raw}' + (float)'{monthly_expenses___expamount2_raw}' + (float)'{monthly_expenses___expamount3_raw}' +(float)'{monthly_expenses___expamount5_raw}'

adding to get my subtraction number of 75
- (float)'{monthly_expenses___expamount2_raw}'+ (float)'{monthly_expenses___expamount3_raw}'+ (float) '{monthly_expenses___expamount_raw}')

Adding to get my divider of 100
/ ((float)'{monthly_expenses___expamount_raw}' + (float)'{monthly_expenses___expamount2_raw}' + (float)'{monthly_expenses___expamount3_raw}' +
(float)'{monthly_expenses___expamount5_raw}')

* 100;

but I get a final % total 125 and it should be 25%

all fields are using 25 for my test and it's 4 fields that are calculating so it's easier to know my answers, they would be either 25,50,75 or 100.
 
ok..wait, I think I got it. I bracketed out the sets of additions I was totaling to get my "total" numbers for each calc like this.


return ((float)'{monthly_expenses___expamount_raw}' + (float)'{monthly_expenses___expamount2_raw}' + (float)'{monthly_expenses___expamount3_raw}' +
(float)'{monthly_expenses___expamount5_raw}') - ((float)'{monthly_expenses___expamount2_raw}'+ (float)'{monthly_expenses___expamount3_raw}'+ (float) '{monthly_expenses___expamount_raw}') / ((float)'{monthly_expenses___expamount_raw}' + (float)'{monthly_expenses___expamount2_raw}' + (float)'{monthly_expenses___expamount3_raw}' +
(float)'{monthly_expenses___expamount5_raw}') * 100;

now i get 25% as a total which is correct.
 
nope it's not right either. It only works if I use 25 as a number if I use 50 in 4 fields it should still be 25% in the end and it's 125....grrrrrr
 
also tried this to tally the observed cells before applying the actual calc, but it always returned 0


$timeTotal = (float)'{monthly_expenses___expamount_raw}' + (float)'{monthly_expenses___expamount2_raw}' + (float)'{monthly_expenses___expamount3_raw}' + (float)'{monthly_expenses___expamount5_raw}';
$subtracttot = (float)'{monthly_expenses___expamount2_raw}'+ (float)'{monthly_expenses___expamount3_raw}'+ (float) '{monthly_expenses___expamount_raw}';
$divtotal = (float) ' monthly_expenses___expamount_raw}' + (float)'{monthly_expenses___expamount2_raw}' + (float)'{monthly_expenses___expamount3_raw}' + (float)'{monthly_expenses___expamount5_raw}';

if ($timeTotal == 0) {
return 0;
}
else {
return (float) $timetotal - $subtracttot / $divtotal * 100;
}
 
ok...tried again with this:


$timeTotal = (float)'{monthly_expenses___expamount_raw}' + (float)'{monthly_expenses___expamount2_raw}' + (float)'{monthly_expenses___expamount3_raw}' + (float)'{monthly_expenses___expamount5_raw}';
$subtracttot = (float)'{monthly_expenses___expamount2_raw}'+ (float)'{monthly_expenses___expamount3_raw}'+ (float) '{monthly_expenses___expamount5_raw}';
$divtotal = (float) ' {monthly_expenses___expamount_raw}' + (float)'{monthly_expenses___expamount2_raw}' + (float)'{monthly_expenses___expamount3_raw}' + (float)'{monthly_expenses___expamount5_raw}';


return $timeTotal - $subtracttot / $divtotal * 100;

Once again I get the correct % total if I enter four "25" as 25 is actually 25% of 100, if I enter 50 four times , 50 should still be 25% of 200, but I'm getting 125% Ireally don't know what I'm doing wrong.
 
lol....well I won't argue that...lol....what do you expect from an Art Major....lol...I can design 50 versions of the letter X, I just can't solve for it!...lol....Thanks for your help
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top