Hi - I'm programming in PHP. Here is some YTD information:
2011 YTD 14,989.3 2,877,688.8 $73,101.97
2010 YTD 18,409.8 1,911,203.4 $52,875.36
YTD Change Down 1.228% Up 1.506% Up 1.383%

The YTD Change % looks incorrect to me. This is the formula I'm using to calculate the percentage. I know you mathematical people will be horrified but I never did very well in math. :( Help!

The numbers are actually right, just the interpretation is off.
1.228 means you have currently 1.228 times last year, so that's a 22.8% increase.
If you get .9 then that's a 10% decrease. Take your number, subtract 1 and multiply by 100.
So (ThisYear/LastYear - 1)*100 gives the percentage change.

The number you generate is the ratio of the new number to the old number. To see the change, you subtract the old number. It's the same as (new - old)/old. With a little algebra, you can see that they are identical.
If you lost 10%, this would actually give you a value of -10% gain. But you want to show the number as positive, so we flip it - (new - old)/old = (-new + old)/old = (old - new)/old = 1 - new/old.
I just short cut the algebra.

Thanks for the explanation! I'm horrific in algebra. :(

Zack

0

Featured Post

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Originally, this post was published on Monitis Blog, you can check it
here
.
In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…

The viewer will learn how to create a basic form using some HTML5 and PHP for later processing.
Set up your basic HTML file. Open your form tag and set the method and action attributes.:
(CODE)
Set up your first few inputs one for the name and …

Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210 (2 * 3 * 5 * 7) or 2310 (2 * 3 * 5 * 7 * 11).
The larger templa…