I'm just putting together a simple spreadsheet that calculates tax owed based on a few different bands. I have an 'Invoiced Amount' cell that takes up the yearly invoicing and then applies a tax rate to it based on the following conditions:
If 'Invoiced Amount' is below 10, 600 then Tax Owed = 0
If 'Invoiced Amount' is above 10, 600 but less than 42, 386 then Tax Owed = ((Invoiced Amount - Tax Allowance)/100) * 20
If 'Invoiced Amount' is Equal to or greater than 42, 386 than Tax Owed = ((42, 386 - Tax Allowance)*20)+((InvoicedAmount - 42, 386)*40)
I could be overlooking something really basic here, but just to be sure - Tax Allowance is 10, 600 - Anything over this up to 42, 386 is worked out at 20% tax, and then anything earn above 42, 386 is charged # 40% on top...
The more I type this out the more confused I am. Anyway, Here is my excel formula:
InvoicedTotal = P5
TaxAllowance (10600) ='UK Tax Figures'!C3
TaxAllowanceUpperBand (42386) ='UK Tax Figures'!G5
TaxAllowance Upper Band - Tax Allowance (31784) = H5
UpperTaxAllownace Band (42386.01) = ='UK Tax Figures'!F5
=IF ((P5)<’UK Tax Figures’!C3, 0, IF(P5>=’UK Tax Figures’!C3<'UK Tax Figures'!G5, ((P5-'UK Tax Figures'!C3)/100)*20, IF(P5>='UK Tax Figures'!F5, ((H5/100)*20)+((P5-'UK Tax Figures'!F5)*40))
At the moment I'm getting crazy unexpected values back, so the calculation is obviously VERY wrong... But I can't see the wood for the trees at the moment, so if anyone has any thoughts I would really appreciate it! Going a little crazy here at the moment!
Putting your formula into the Online Excel Formula beautifier I notice several problems with your formula:
=IF ( ( P5 ) < ’UK Tax Figures’!C3 , 0 ,
IF(
P5 >= ’UK Tax Figures’!C3 < UKTaxFigures!G5,
( ( P5 - UKTaxFigures!C3 ) / 100 ) * 20,
IF(
P5 >= UKTaxFigures!F5,
( ( H5 / 100 ) * 20 ) + ( ( P5 - UKTaxFigures!F5 ) * 40 )
)
First of all, you lack two closing parantheses
Furthermore, you have an invalid conditional in P5>=’UK Tax Figures’!C3<'UK Tax Figures'!G5, you need to change this to AND(P5>=UKTaxFigures!C3;UKTaxFigures!C3<UKTaxFigures!G5).
Taking a look at how you reference your worksheets above, I notice that it seems you have two different sheets - one with spaces between the words in the sheet names, and one without. I suspect this is not the case, so you should probably remove those spaces from the formula.
You are also inconsistent with whether or not you use apostrophes (’) around your sheet-names. Trying out your formula in a cell, Excel didn't seem to like them, so they should probably go as well.
there seems to be a return-value missing from your innermost if-statement if it is false.
Guessing a bit at what you want the formula to return, I end up with this formula:
=IF(P5<UKTaxFigures!C3;0;IF(AND(P5>=UKTaxFigures!C3;UKTaxFigures!C3<UKTaxFigures!G5);((P5-UKTaxFigures!C3)/100)*20;IF(P5>=UKTaxFigures!F5;((H5/100)*20)+((P5-UKTaxFigures!F5)*40);0)))
Which looks like this in the beautifier:
=IF(
P5 < UKTaxFigures!C3;
0;
IF(
AND(
P5 >= UKTaxFigures!C3;
UKTaxFigures!C3 < UKTaxFigures!G5
);
( ( P5 - UKTaxFigures!C3 ) / 100 ) * 20;
IF(
P5 >= UKTaxFigures!F5;
( ( H5 / 100 ) * 20 ) + ( ( P5 - UKTaxFigures!F5 ) * 40 );
0
)
)
)
Is that something close to what you want?
As a final word of advice it is an absolute pain to write a formula like that - instead you can try to build it bit by bit, storing each part of the formula in one cell to see if each of them works. Then you can cut and paste so that they all fit in one cell. I.e. if you in cell A1 store:
=IF(P5>=UKTaxFigures!F5;((H5/100)*20)+((P5-UKTaxFigures!F5)*40);0)
Then you can put
=IF(AND(P5>=UKTaxFigures!C3;UKTaxFigures!C3<UKTaxFigures!G5);((P5-UKTaxFigures!C3)/100)*20;A1)
in A2 and this
=IF(P5<UKTaxFigures!C3;0;A2)
in A3. If necessary you can pick the formulas even further apart to make them more readable. Then in the end you just copy the formulas from the cells, and replace the references with them.
Please note that I am not 100 % certain that I got everything correct, without proper data it is somewhat difficult to keep track of all the parantheses and results. But this should at least give you a good starting point.
Related
I have 2 tables and need to use criteria from table1 (Team) to look up information from Schedule2 (Team's Schedule for the year) and then use that array from Schedule2 to find the matches in table1 (opponents) and pair that with the criteria of matching the position within table 1 (position = position) to then sum up the associated numbers that match (2021 opp position points) to calculate the expected total points for the year.
In English: use the team to look up the schedule, use the schedule to look up the array of opponents the team has for the year, use the array of opponents for the year to find the opponents in table1, and then match the position of the current row to the position that is playing each of those opponents, and then sum up the associated points.
Goal: This is to calculate a forecast of each team's position's total points for the year based on how many points their opponents for the year are currently giving away to each position.
Explained Example: So if Dallas WR plays NYG, MIA, WAS, and MIA again, sum up the total points NYG, MIA, WAS, and MIA are currently giving to WRs they are currently play against.
FYI WR = Wide Receiver RB = Running Back, TE = Tight End D/ST = Defense string, QB = Quarterback
I can't use helper cells and need a single formula. Schedule2 will give duplicate values (Some teams play the same team twice and each of those values need to be calculated and not considered unique and not counted just once.
The current formula I have is below but it only seemed to work for one row and didnt work when I drug it down to the row below. could be a referencing issue but I didnt notice anything that would cause this.
The first part of the formula is meant to get the total for the non-duplicated values and the second is meant to get the duplicated values.
= SUM( IF( ISERROR( MATCH( Table1[[#All],[Position]],G14,0)
* MATCH(Table1[[#All],[Opponent]],INDEX(Schedule2,0,MATCH(Table1[#Team],Schedules!$AU$3:$CA$3,0)),0) ),
0,
Table1[[#All],[2021 Opp Position]]))
+ SUM( IF( ISERROR( MATCH( Table1[[#All],[Opponent]],
IF( COUNTIF( INDEX( Schedule2, 0, MATCH(Table1[#Team],Schedules!$AU$3:$CA$3,0) ), INDEX(Schedule2,0,MATCH(Table1[#Team],Schedules!$AU$3:$CA$3,0)))=2,
INDEX(Schedule2,0,MATCH(Table1[#Team],Schedules!$AU$3:$CA$3,0)),
""), 0 )
* MATCH(Table1[[#All],[Position]],G14,0)
* MATCH(Table1[[#All],[Opponent]],INDEX( Schedule2,
0,
MATCH(Table1[#Team],Schedules!$AU$3:$CA$3,0) ),0) ),
0,
Table1[[#All],[2021 Opp Position]] ) )
I have a spreadsheet with:
list of recurrent expenses
other lists of recurring stuff, not important
an estimation of inflow and outflow monthly
The estimation is calculated with the following criteria (in AND logic):
date is between "since" and "to" (if since is empty, it is always valid, and the same for "to")
the month is a multiple of "every month" starting from "since", i.e. the voice must be included if "data" = "since" + "every months" * x, where x is an integer number
I wanted to create a sumifs like the following (Italian Excel, sorry):
=SOMMA.PIÙ.SE('Uscite'!$E$2:$E$1048576;'Uscite'!$C$2:$C$1048576;"<="&'v3'!$A2;'Uscite'!$D$2:$D$1048576;">="&'v3'!$A2;?????)
where ????? is the missing piece: I considered using a DATEDIF with "m", in order to get the difference in months between cell Ax and 'Uscite'!Since, then verifying if this difference is a perfect multiple of "every months", but no clue how to do it.
Any suggestion?
Thanks for your time!
In english formulation, you could do:
=SUM( 'Entrate ricorrenti'!$E$2:$E$100 *
( ('Entrate ricorrenti'!$D$2:$D$100 >= 'v3'!A2) + ISBLANK('Entrate ricorrenti'!$D$2:$D$100) ) *
IFERROR( MOD( DATEDIF( 'Entrate ricorrenti'!$C$2:$C$100, 'v3'!A2, "M" ), 'Entrate ricorrenti'!$B$2:$B$100 ) = 0,
0 ) )
In Italian:
=SOMMA( 'Entrate ricorrenti'!$E$2:$E$100 *
( ('Entrate ricorrenti'!$D$2:$D$100 >= 'v3'!A2) + VAL.VUOTO('Entrate ricorrenti'!$D$2:$D$100) ) *
SE.ERRORE( RESTO( DATA.DIFF( 'Entrate ricorrenti'!$C$2:$C$100; 'v3'!A2; "M" ); 'Entrate ricorrenti'!$B$2:$B$100 ) = 0;
0 ) )
So, this uses the very nice dinosaur function that you taught me about today. I have never seen this except for DAX.
It simply filters out the payments that stopped before the target date, ('v3'!A2) by multiplying the payment values, ('Entrate ricorrenti'!$E$2:$E$100), times the boolean expression
(('Entrate ricorrenti'!$D$2:$D$100 >= 'v3'!A2) + ISBLANK('Entrate ricorrenti'!$D$2:$D$100))
that also checks to see if the To Date is blank. Then it multiplies that times the modulo of the DATEDIF in months by the Frequency in months. If that is zero, then a payment lands in that month. DATEDIF has the nice property that if the date difference is negative, it generates an N/A error. This allows us to wrap it in an IFERROR to replace that with zero - this prevents the formula from including payments that have not yet started.
I'm trying to devise a dynamic spread sheet involving pension contribution percentages which increases with the age of the employees.
I've used the =now() function to calculate their ages on a dynamic basis and I now need to get excel to look at their age in cell H2 and apply the following criteria, altering automatically as their age increases into the next bracket:
if they are currently aged between 18 - 39 pension contribution is 6%
between 40 - 49 it is 7%
and over 50 it is 10%
The formula I've devised is picking up the correct percentages for those 39 & under and for those 50+ but I can't get it to recognize the 7% for those between 40 - 49.
Can anybody tell me where I'm going wrong?
=IF(H2>=OR18<=39,"6%",IF(H2>=OR40<=49,"7%",IF(H2>=OR50>100,"10%")))
Hi and welcome to Stack Overflow!
So assuming the value to test is in cell A1, the basic formula for matching within a range (say 1-10) is:
=IF(AND(A1 >= 1, A1 <= 10), "In Range", "Out of Range")
So expanding this to 3 ranges (18-39, 40-49, and 50+), and substituting your percentages, we get:
=IF(AND(A1 >= 18, A1 <= 39), "6%", IF(AND(A1 >= 40, A1 <= 49), "7%", IF(A1 >= 50, "10%")))
So a loose end that needs tying up is what to do if the age is less than 18 - currently this formula will produce FALSE. You might want to put something else in by adding a result for the second condition in the last test - so where the value doesn't match >= 50, e.g.
... IF(A1 >= 50, "10%", "NOT APPLICABLE") ...
or some other value that's appropriate.
I have done an average price calculation for apples. See example
In the new column "testar", I only want to show the year 1990 - 1994 (yellow cells), since the other years are not specified in my formula.
Formula I used for average calculation was:
=CALCULATE (
AVERAGEX (Datasrc; Datasrc[C_P2] );
DATESBETWEEN(Datasrc[Year];"1990-01-01";"1994-01-01")
)
Any ideas or advice how to do that?
You'll need to test the values of Datasrc[Year] in an IF().
Here's a sample using a dummy dataset I have.
Testar =
IF(
MAX( DimDate[Year] ) > 2010
&& MAX( DimDate[Year] ) < 2014
,[SumAmt]
)
We're testing MAX() DimDate[Year]. On any given pivot row, only one year is in context, so max is the year on that pivot row.
The measure you used calculates the average in the context of the 5 years you've defined, overriding whatever the current filter context is.
Additionally, AVERAGEX() is unnecessary in this situation; you can use AVERAGE( Datasrc[C_P2] ).
Almost, thank you for your valuable input and put me in the right direction!!!, since my format of the year table is different and I want to have the average price listed I did a little different. I simply combined your formula with my average formula and got the result I wanted.
See final result here
Code used:
=IF(
MAX( Datasrc[Year2] ) >= 1990
&& MAX( Datasrc[Year2] ) <= 1994
;
CALCULATE (
AVERAGEX (Datasrc; Datasrc[C_P2] );
DATESBETWEEN(Datasrc[Year];"1990-01-01";"1994-01-01")
)
)
The first part of the formula, takes out only the years I'm interested in.
The second part of the formula [CALCULATE(AVERAGEX....] calculates the average of the years I'm interested of.
I have a retail store that sells items on consignment for a fee that varies based on Selling Price.
So my question is how do I write a formula that checks the selling price and then charges the correct consignment fee to calculate the net based on the following schedule:
When selling price is over $400 then charge = 20%
When Selling price is $100 to $400 then charge = 30%
When Selling price is under $100 then charge = 40%
BLUF: use nested IF statements (an IF inside an IF) --
Example:
=IF(A2>=400, (A2*0.2), (IF(400 > A2 >= 100, (A2 *0.3), (A2*0.4))))
Or use the below if you suspect someone will foolishly enter a negative number or something nonsensical:
=IF(A2>=400, (A2*0.2), (IF(400 > A2 >= 100, (A2 *0.3), (IF(A2 < 100, (A2*0.4), (0))))))
That may look complex, but let's break it down from the beginning.
The basic formula for the IF statement:
=IF(testCondition, (resultIfTrue), (resultIfFalse))
One IF statement will only allow you to do two of your 3 conditions:
=IF(A1 > 400, (A1 * .20), (A1 * .30))
The above basically says that if the number in cell A1 is greater than 400, then the value in your current cell (e.g. B2) is A1 * 20%. But if the number in A1 is NOT greater than 400, the value in your cell will be A1 * 30%.
But how do we calculate the range you were asking (i.e. 100 - 400) and how do we add in a third possibility (i.e. the possibility that the number is less than 100)?
The answer is to use a nested IF. You can tell the cell what it's value should be if the condition is true, but you can test another condition if the answer is false (i.e. the next IF statement stands in the place of resultIfFalse.
=IF(testCondition, (resultIfTrue), (IF(testCondition, (resultIfTrue), (resultIfFalse))))
The above can handle 3 different scenarios. Out of the IFs above, you could also replace the second IFs resultIfFalse with yet another IF statement, and so on. You can nest up to 64 IF statements.
Extra Resources:
http://fiveminutelessons.com/learn-microsoft-excel/using-multiple-if-statements-excel
http://spreadsheets.about.com/od/tipsandfaqs/qt/nested_if.htm
Nested IF functions are not user friendly and require hardcoding your variables (percentages). My suggestion would always be to have a small table of values elsewhere: eg. put the following in A1:B3
0 0.4
100 0.3
401 0.2
Assuming your data is in D1 you can use the following formula in E1 and drag down if necessary
=INDEX($B$1:$B$3,MATCH($D1,$A$1:$A$3,1))
This way you can change your boundaries/ add more conditions easily without more nested IF statements
Try using this instead:
=IF(B1<100,B1*40%,IF((B1>=100)*AND(B1<=400),B1*30%,IF(B1>100,B1*20%,"Invalid Price"))
This formula contains nested-ifs and a logical AND condition which will give the result.