Forum Discussion
Calculation of truck consumption
- Sep 24, 2024
vitoaiaco first I must say I'm not a fan of you sheet set up.
a) It appears you insert columns to enter the latest data which can/will throw problems into calculation.
b) you are using columns instead of rows (you have many more rows than columns)
c) you are grouping data/columns instead of having individual entries.
that all said the following formula will work:
=LET(miles, FILTER(D6:AAA6,(D$3:AAA$3="KM")*(D6:AAA6<>"")), gas, FILTER(D6:AAA6,(D$3:AAA$3="Diesel Ltrs")*(D6:AAA6<>"")), (INDEX(miles,1)-INDEX(miles,2))/INDEX(gas,2))
or you could use INDEX or CHOOSECOLS instead of FILTER
That said, you may want or need to add a 'dummy' column D so the formula wont get shifted when you insert the columns.
Lastly I question your calculation because I always do current milage - last milage / how much I need to fill the tank NOW as how much I used which assumes I top the tank off. Your calculation using the prior gas amount works if you run the engine dry each time (which I sencerely doubt) or I'm just misunderstanding the data.
vitoaiaco first I must say I'm not a fan of you sheet set up.
a) It appears you insert columns to enter the latest data which can/will throw problems into calculation.
b) you are using columns instead of rows (you have many more rows than columns)
c) you are grouping data/columns instead of having individual entries.
that all said the following formula will work:
=LET(miles, FILTER(D6:AAA6,(D$3:AAA$3="KM")*(D6:AAA6<>"")),
gas, FILTER(D6:AAA6,(D$3:AAA$3="Diesel Ltrs")*(D6:AAA6<>"")),
(INDEX(miles,1)-INDEX(miles,2))/INDEX(gas,2))
or you could use INDEX or CHOOSECOLS instead of FILTER
That said, you may want or need to add a 'dummy' column D so the formula wont get shifted when you insert the columns.
Lastly I question your calculation because I always do current milage - last milage / how much I need to fill the tank NOW as how much I used which assumes I top the tank off. Your calculation using the prior gas amount works if you run the engine dry each time (which I sencerely doubt) or I'm just misunderstanding the data.
- vitoaiacoSep 24, 2024Brass ContributorThank you! This works perfectly!
Much appreciated