Nested IF Statements in Numbers

Hello!


I'm a real estate agent and am making a spreadsheet to figure out my income before and after taxes since I have to figure it myself. I like to know and be able to look at and change values in my own spreadsheet that will then calculate. I have everything perfectly set up except for the "after taxes" portion where I am calculating (in laymen's terms) "if my income is less than or equal to a certain value, then multiply it by this percentage and output Error if not calculable." I'm doing it based on the current tax brackets and will update it once I have the new brackets.


The current brackets are as follows:

$0 to $9525; 10%

$9,526 to $38,700; $952.50 plus 12% of the amount over $9,525

$38,701 to $82,50; $4,453.50 plus 22% of the amount over $38,700

$82,501 to $157,500; $14,089.50 plus 24% of the amount over $82,500

$157,501 to $200,000; $32,089.50 plus 32% of the amount over $157,500

$200,001 to $500,000; $45,689.50 plus 35% of the amount over $200,000

$500,001 or more; $150,689.50 plus 37% of the amount over $500,000

MacBook Pro (Retina, 15-inch, Mid 2015)

Posted on Sep 18, 2018 1:05 PM

Reply
Question marked as Top-ranking reply

Posted on Sep 18, 2018 10:33 PM

Hi Cody,


Nested IFs are fine up to a triad. Beyond that, they become cumbersome, error prone, and difficult to edit.


The Canadian tax form has a table very similar to the description you provided (but with fewer tax brackets). The same process can be constructed using a Lookup table containing the threshold amounts, amounts due at each threshold, and rates after each threshold.


Here's your list of rates and threshold amounts at which each rate applies, translated to a Rates table:

User uploaded file

Column A contains a list of the threshold amounts at which each rate is applied. This is entered directly.

Column C contains the rate that applies to amounts from the threshold amount listed in 'this row' to the amount shown in the next row. These rates are entered directly.

Column B contains the amounts due at each threshold. The first of these, 0.00 (due on a taxable amount of $0) is entered directly. the rest are calculated by the formula shown below the table. The formula is entered in B3, then filled down to the last row of column A.


B3: IF(LEN(A3)<1,"",B2+C2×(A3−A2))


The IF part, shown in normal weight type, is a 'switch' that prevents calculation if there is no value entered in 'this row' of column A. The core formula that does the calculations is shown in bold.


In English, the core formula says: 'the amount due at the previous threshold (B2), plus the rate to 'this threshold' (C3) multiplied by (the amount at 'this threshold' (A3) minus the amount at the previous threshold (A2) )


The entered and constructed data in this table are used to calculate the amount due in the Calculations table:

User uploaded file

The calculations table here has many rows to show the results obtained from several different input amounts. In practice, this would likely be a single pair of cells in a larger table.


What the formula does:


Each INDEX section uses the same MATCH statement: MATCH(A2,Rates::A,1)

This gets the value in Calculation::A2, searches for a match in Column A of Rates, accepts the largest value less than or equal to the value in A2 of Calculations, and returns a number indicating the position of tha value in the list in column A of Rates.


Each INDEX uses that number to determine the row from which it is to return the values requested below


INDEX(Rates::B,MATCH(A2,Rates::A,1))+ The amount due at the largest threshold amount less than or equal

to the Amount in Calculations::A2 plus

INDEX(Rates::C,MATCH(A2,Rates::A,1))× The the tax rate within the current bracket (tier), multiplied by

(A2−INDEX(Rates::A,MATCH(A2,Rates::A,1))) (The the Amount in Calculations::A2 minus the threshold amount

at the beginning of this bracket (tier) )


If rates change, a tier is added or removed, or the amounts at which each rate applies is changed, the only editing to be done is to enter the new threshold values in Column A of Rates and enter the new rates in column C of Rates (and fill the first forula into new rows if tiers have been added to the Rates table).

NO changes to either formula are required.


COPY/PASTE version of the full second formula:

INDEX(Rates::B,MATCH(A2,Rates::A,1))+INDEX(Rates::C,MATCH(A2,Rates::A,1))×(A2−IN DEX(Rates::A,MATCH(A2,Rates::A,1)))



Regards,

Barry

2 replies
Question marked as Top-ranking reply

Sep 18, 2018 10:33 PM in response to codyiphone4

Hi Cody,


Nested IFs are fine up to a triad. Beyond that, they become cumbersome, error prone, and difficult to edit.


The Canadian tax form has a table very similar to the description you provided (but with fewer tax brackets). The same process can be constructed using a Lookup table containing the threshold amounts, amounts due at each threshold, and rates after each threshold.


Here's your list of rates and threshold amounts at which each rate applies, translated to a Rates table:

User uploaded file

Column A contains a list of the threshold amounts at which each rate is applied. This is entered directly.

Column C contains the rate that applies to amounts from the threshold amount listed in 'this row' to the amount shown in the next row. These rates are entered directly.

Column B contains the amounts due at each threshold. The first of these, 0.00 (due on a taxable amount of $0) is entered directly. the rest are calculated by the formula shown below the table. The formula is entered in B3, then filled down to the last row of column A.


B3: IF(LEN(A3)<1,"",B2+C2×(A3−A2))


The IF part, shown in normal weight type, is a 'switch' that prevents calculation if there is no value entered in 'this row' of column A. The core formula that does the calculations is shown in bold.


In English, the core formula says: 'the amount due at the previous threshold (B2), plus the rate to 'this threshold' (C3) multiplied by (the amount at 'this threshold' (A3) minus the amount at the previous threshold (A2) )


The entered and constructed data in this table are used to calculate the amount due in the Calculations table:

User uploaded file

The calculations table here has many rows to show the results obtained from several different input amounts. In practice, this would likely be a single pair of cells in a larger table.


What the formula does:


Each INDEX section uses the same MATCH statement: MATCH(A2,Rates::A,1)

This gets the value in Calculation::A2, searches for a match in Column A of Rates, accepts the largest value less than or equal to the value in A2 of Calculations, and returns a number indicating the position of tha value in the list in column A of Rates.


Each INDEX uses that number to determine the row from which it is to return the values requested below


INDEX(Rates::B,MATCH(A2,Rates::A,1))+ The amount due at the largest threshold amount less than or equal

to the Amount in Calculations::A2 plus

INDEX(Rates::C,MATCH(A2,Rates::A,1))× The the tax rate within the current bracket (tier), multiplied by

(A2−INDEX(Rates::A,MATCH(A2,Rates::A,1))) (The the Amount in Calculations::A2 minus the threshold amount

at the beginning of this bracket (tier) )


If rates change, a tier is added or removed, or the amounts at which each rate applies is changed, the only editing to be done is to enter the new threshold values in Column A of Rates and enter the new rates in column C of Rates (and fill the first forula into new rows if tiers have been added to the Rates table).

NO changes to either formula are required.


COPY/PASTE version of the full second formula:

INDEX(Rates::B,MATCH(A2,Rates::A,1))+INDEX(Rates::C,MATCH(A2,Rates::A,1))×(A2−IN DEX(Rates::A,MATCH(A2,Rates::A,1)))



Regards,

Barry

Sep 18, 2018 4:34 PM in response to codyiphone4

Though the formula is unusually long, I find the easiest solution to a "tiered rate" problem like this is the following:


User uploaded file


If the pretax income is in A2, then I use a formula like this:


=MAX(0,(MIN(9525,A2)−0))*0.1
+MAX(0,(MIN(38700,A2)−9525))*0.12
+MAX(0,(MIN(82500,A2)−38700))*0.22
+MAX(0,(MIN(157500,A2)−82500))*0.24
+MAX(0,(MIN(200000,A2)−157500))*0.32
+MAX(0,(MIN(500000,A2)−200000))*0.35
+MAX(0,(MIN(1000000,A2)−500000))*0.37


As explained in the screenshot the formula, when broken down line by line, is much simpler than it looks and is easy to edit when the brackets change.


Substitute ; for , in the formula if your region uses , as a decimal separator.


SG

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Nested IF Statements in Numbers

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.