excel - Formula should be simple -


im bit of rookie excel , cant find exact answer question.

basically want picture 1(https://i.stack.imgur.com/8e5zv.png) picture 2 (https://i.stack.imgur.com/lxjhq.png ) showing. easy question.

so value total on 10,000 charged @ 25p rate , value below 10,000 charged 40p rate.

so cumulatively, 1 person may have claimed 9999 miles since starting , put in new expense claim 10 miles, 1 mile go 40p rate , other 9 25p rate.

what sort of formula need?

thanks in advance!

if previous cumulative mileage denoted old, additional mileages miles , threshold @ lower rate payable thold consider following. there 3 cases:

  1. old+miles<=thold: miles paid @ higher rate
  2. old<thold<=old+miles: miles split thold-old paid @ higher rate , miles-(thold-old) @ lower rate
  3. thold<=old: miles paid @ lower rate.

miles paid @ higher rate whenever old less thold , number of miles paid @ higher rate lesser of miles (case 1.) , thold-old (case 2.). expressed in excel-like way as

`=if(thold-old>0,if(miles<thold-old,miles, thold-old),0)` 

but more succinct expression is

`=min(miles,max(thold-old,0))` 

both formulae, deliver correct result in 3 cases (including value of 0 case 3.) , each represents applicable formula number of miles paid @ higher rate.

similarly, miles paid @ lower rate whenever old+miles exceeds thold , number paid @ rate lesser of miles (case 3.) , miles-(thold-old) (case 2.). in case if expression is:

`=if(old+miles>thold,if(miles<miles-(thold-old),miles,miles-(thold-old)),0) 

but can equivalently written as

`=if(old+miles-thold>0,if(miles<miles+old-thold,miles, miles+old-thold),0)` 

and leave exercise work out succinct version. formula(e) deliver result of 0 case 1. , applicable calculating miles paid @ lower rate.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -