Forum Discussion
Conor5283
Apr 03, 2019Copper Contributor
Calculating Mileage
Hi I am creating a template for expenses, when calculating Mileage for the first 10000 miles it is billed at £0.45 anything over 10000 is £0.25. I cant seem to figure out a formula that will work for...
JKPieterse
Apr 03, 2019Silver Contributor
Does this fit your needs:
=IF([@Description]="Mileage",MIN([@Distance],10000)*Table26[Mileage Allowance (<10000)]+MAX(0,[@Distance]-10000)*Table26[Mileage Allowance (>10000)],0)
=IF([@Description]="Mileage",MIN([@Distance],10000)*Table26[Mileage Allowance (<10000)]+MAX(0,[@Distance]-10000)*Table26[Mileage Allowance (>10000)],0)
- Conor5283Apr 03, 2019Copper Contributor
Not quite, for example if I enter 10050 I need it to calculate the 10000 @0.45 and then the 50 @0.25, then each subsequent entry after this would need to calculate at 0.25 as it is past the threshold of 10k
JKPieterse wrote:
Does this fit your needs:
=IF([@Description]="Mileage",MIN([@Distance],10000)*Table26[Mileage Allowance (<10000)]+MAX(0,[@Distance]-10000)*Table26[Mileage Allowance (>10000)],0)- SergeiBaklanApr 03, 2019Diamond Contributor
Conor5283 , if it us assumed cumulative mileage, when for that sample
that could be
=IF([@Description]="Mileage", MIN(SUMIF(INDEX([Description],1):[@Description],"Mileage",INDEX([Distance],1):[@Distance]),10000)*$G$4+ MAX(0,SUMIF(INDEX([Description],1):[@Description],"Mileage",INDEX([Distance],1):[@Distance])-10000)*$G$5,0)
- JKPieterseApr 03, 2019Silver ContributorWithout an idea of your data this is hard to answer. Are you saying this must not be calculated on a per-row basis but that we need to keep a running total of mileage?