We have a company page to track mileage on company vehicles, and at the end of every month the driver enters the ending odometer reading. I wrote a formula to figure out the mileage for the year by taking each month and subtracting the previous month, and then adding each of those results. It worked, and looks like this:
=([Jan 13]-[2012 Ending])+([Feb 13]-[Jan 13])+([Mar 13]-[Feb 13])+([Apr 13]-[Mar 13])+([May 13]-[Apr 13])+([Jun 13]-[May 13])+([Jul 13]-[Jun 13])+([Aug 13]-[Jul 13])+([Sep 13]-[Aug 13])+([Oct 13]-[Sep 13])+([Nov 13]-[Oct 13])+([Dec 13]-[Nov 13])
Problem is, until you have every month filled in, you get negative numbers and an incorrect result...Because "0" minus last month's mileage is a negative. So I wrote an IF statement into each month that evaluates whether or not the current month is still zero, and if so returns zero...which should fix the math problem...
=IF([Jan 13]>0, [Jan 13]-[2012 Ending],"0")
=IF([Feb 13]>0, [Feb 13]-[Jan 13],"0")
=IF([Mar 13]>0, [Mar 13]-[Feb 13],"0")
=IF([Apr 13]>0, [Apr 13]-[Mar 13],"0")
=IF([May 13]>0, [May 13]-[Apr 13],"0")
=IF([Jun 13]>0, [Jun 13]-[May 13],"0")
=IF([Jul 13]>0, [Jul 13]-[Jun 13],"0")
=IF([Aug 13]>0, [Aug 13]-[Jul 13],"0")
=IF([Sep 13]>0, [Sep 13]-[Aug 13],"0")
=IF([Oct 13]>0, [Oct 13]-[Sep 13],"0")
=IF([Nov 13]>0, [Nov 13]-[Oct 13],"0")
=IF([Dec 13]>0, [Dec 13]-[Nov 13],"0")
The problem now is to string them all together...And that's where I get the error. Putting it all together should look something like...?
=SUM(=IF([Jan 13]>0, [Jan 13]-[2012 Ending],"0")+(=IF([Feb 13]>0, [Feb 13]-[Jan 13],"0")+(=IF([Mar 13]>0, [Mar 13]-[Feb 13],"0")+(=IF([Apr 13]>0, [Apr 13]-[Mar 13],"0")+(=IF([May 13]>0, [May 13]-[Apr 13],"0")+(=IF([Jun 13]>0, [Jun 13]-[May 13],"0")+(=IF([Jul 13]>0, [Jul 13]-[Jun 13],"0")+(=IF([Aug 13]>0, [Aug 13]-[Jul 13],"0")+(=IF([Sep 13]>0, [Sep 13]-[Aug 13],"0")+(=IF([Oct 13]>0, [Oct 13]-[Sep 13],"0")+(=IF([Nov 13]>0, [Nov 13]-[Oct 13],"0")+(=IF([Dec 13]>0, [Dec 13]-[Nov 13],"0"))
But my syntax is wrong somewhere...Help!
