Download presentation
Presentation is loading. Please wait.
1
Logical tests
2
Logical tests Consider an income tax system in which a fixed allowance of £4000 is awarded against gross income, i.e. no tax is paid on first £4000 earned. First £16000 is taxed at 20% Over £16000 the rate is 25%
3
Continued… If you earn £30000
Taxable income (TI) = £ £4000 = £26000 First £16000 of this is taxed at 20%; 20/100*£16000 = £3200 The remaining £10000 is taxed at 25%; 25/100*£10000 = £2500 Therefore total tax bill is £3200+£2500=£5700 Net income is £30000-£5700=£24300
4
In Excel… We can use the IF statement Let G be gross income
A be the tax free allowance Taxable income, TI=G-A Check to see where any tax should be paid =IF(G-A<0,0, G-A)
5
… Now to calculate the amount of tax
If TI is less than the upper limit, M, then the tax is simply = lower rate * TI If TI is greater than M, then the tax is lower rate*TI + upper rate * (TI-M) Translating into an IF statement, =IF(G-A<=M, lower*(G-A), lower*M+upper*(G-A-M))
6
Naming cells To assign a name to a cell, highlight the cell and from the menu choose INSERT>NAME>DEFINE This can be very useful in keeping track of entries in formulae, especially as it means you do not have to use $ to fixed the cell you are referring to.
7
… Note that the cells A, tl, th, M, G, TI, TD and NI are all named cells Note lower rate = tl, higher rate =tu Try this on your own without naming the cells, what do you think will happen?
8
Vertical lookups How do we deal with situations where there may be more than two or three embedded IF statements, when it may get rather messy? Imagine a firm is selling kitchen units offers a range of discount rates depending on the size of the order.
9
Example For orders less than 10 units, there is no discount
Orders >=10 but <25 a 4% discount is offered Orders >=25 but <45 a 6% discount is offered Orders >=45 but <75 a 7% discount is offered Orders >=75but <100 a 7.5% discount is offered Orders >=100 a 9% discount is offered
10
… We use the VLOOKUP statement
11
Define the lookup table
The order size is stored in cell B3 The different discount rates are stored in cells D3:E8 We want to return the values from column 2 of the lookup table The statement is therefore = VLOOKUP(B3, D3:E8, 2)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.