简体   繁体   中英

Excel “IF” formula: Calculate Brokerage Fees

I'm a beginner with Excel and what I'm trying to do is my simple calculation regarding a brokerage fees. Here's the fees I need to pay:

Stock value under MYR 1000 : Stamp duty MYR 1.
Stock value under MYR 2000 : Stamp duty MYR 2.
Stock value under MYR 3000 : Stamp duty MYR 3.

And it keep going on until Stock value under MYR 200,000 and stamp duty will be halted at MYR 200. Whenever the stock value above MYR 200,000, stamp duty that need to be paid still MYR 200.

So, basically I've made my "IF" formula and seems like this thing taking forever. This is the formula that I worked on it;

=IF(L31>=37001,38,IF(L31>=36001,37,IF(L31>=35001,36,IF(L31>=34001,35,IF(L31>=33001,34,IF(L31>=32001,33,IF(L31>=31001,32,IF(L31>=30001,31,IF(L31>=29001,30,IF(L31>=28001,29,IF(L31>=27001,28,IF(L31>=26001,27,IF(L31>=25001,26,IF(L31>=24001,25,IF(L31>=23001,24,IF(L31>=22001,23,IF(L31>=21001,22,IF(L31>=20001,21,IF(L31>=19001,20,IF(L31>=18001,19,IF(L31>=17001,18,IF(L31>=16001,17,IF(L31>=15001,16,IF(L31>=14001,15,IF(L31>=13001,14,IF(L31>=12001,13,IF(L31>=11001,12,IF(L31>=100001,11,IF(L31>=9001,10,IF(L31>=8001,9,IF(L31>=7001,8,IF(L31>=6001,7,IF(L31>=5001,6,IF(L31>=4001,5,IF(L31>=3001,4,IF(L31>=2001,3,IF(L31>=1001,2,IF(L31>=1,1))))))))))))))))))))))))))))))))))))))

So, my question is, is there any simple formula that suit the rules written is first paragraph?

Thank you so much.

Although VLOOKUP is the classic way of eliminating all the IF's, in this particular case, a formula solution is also possible due to the relationships:

=MIN(INT((L31-1)/1000)+1,200)

seems to give the same results as what your formula would expect.

Based on the consistency in the format of the cells, you can use LEN() to check the length of the number then format accordingly.

IF(LEN(L31)=5,LEFT(L31,2)+1 - If the length is 5 characters, take the first 2 characters and add 1.

,IF(LEN(L31)=4,LEFT(L31,1)+1 - if the length is 4 characters, take the first characters and add 1.

,1)) - if nothing else matches, the value is 1.

=IF(LEN(L31)=5,LEFT(L31,2)+1,IF(LEN(L31)=4,LEFT(L31,1)+1,1))

On a separate note, you had a typo in your formula (100001 should have been 10001).

Your nested IF formula can be replaced with one as simple as this:

=VLOOKUP($B$6,$A$2:$B$4,2)

This is a classic use case of VLOOKUP with no false parameter passed.

You can search for VLOOKUP to see how that would work.

It's much simpler than trying to nest IF statements.

Example

Let's say you have the following 2-column table, with row 1 as headings:

          COLUMN A         COLUMN B
          -----------      ----------------
Row 1:    Stock value      Stamp duty (MYR)
Row 2:              0                     1
Row 3:           1000                     2
Row 4:           2000                     3

Let's say you have a stock value in cell B6.

Your lookup formula (in some other cell, say B7) would simply be:

=VLOOKUP($B$6,$A$2:$B$4,2)

You can then extend this table down until that last row has 200,000 in column A. (Don't forget to ensure the formula is referring to the new rows too).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM