Nesting If statement "AND" conditionals in Excel - excel

I am having trouble with the logic of nesting if statements to check if the previous 4 cells are greater than 0.
What I am trying to do is calculated a luxury tax on a baseball team.
Originally, I wrote:
=IF(C74>J74,C74+(C74-J74)*IF(I71<>0*I72<>0*I73<>0, 0.5, IF(I72<>0*I73<>0,0.4,IF(I73<>0,0.3,0.175))), 0)
But it sums up all 4 years and doesn't factor in the consecutive idea.
Then I tried:
If they go over the salary tax threshold:
the first time then there is a 17.5% tax on the amount over:
if(C74>J74, I74*0.175, 0)
the second consecutive time there is a 30% tax on the amount over:
if(C74>J74, if(C73>J73, I74*0.3), I74*0.175), 0)
The third consecutive time there is a 40% tax:
if(C74>J74, if(C73>J73, if(C72>J72, I74*0.3), I74*0.175), 0)
And the fourth consecutive time there is a 50% tax:
if(C74>J74, if(C73>J73, if(C72>J72, if(C71>J71, I74*0.5), I74*0.3), I74*0.175), 0)
Straight from Wikipedia:
The threshold level for the luxury tax will be $189MM in 2014 (up from $178MM from 2011-2013) and will remain at $189MM through 2016. From 2012 through 2016, teams who exceed the threshold for the first time must pay 17.5% of the amount they are over, 30% for the second consecutive year over, 40% for the third consecutive year over, and 50% for four or more consecutive years over the cap.[4]
In my forumla, currently if a team goes over the luxury tax, then under, then over again- the calculation will still apply a 40% tax instead of 17.5.
Is there anyway check the conditions of the four preceding cells without having to write jumbled nested ifs like I am about to do?

I'd add a new column with a single IF statement, if the value is greater than the cap, then 1, otherwise 0. Then when you figure the tax, take the sum of "this" row's cell plus the three above it, and that tells you the number of years in this plus the last 4 that they're over. Which is what you're doing now, it sounds like.
If you want to just know CONSECUTIVE years, you could do something like,
if(sum(4 values)=4,50%,if(sum(3 values)=3,40%,if(sum(2 values)=2,30%,if(thisRow=1,17.5%,0%))))
That gives you the tax rate, and you can multiply the value its taxing in the same cell or elsewhere.
Hope that helps!

Related

Find maximum whole number divisor of an amount

Here is the spreadsheet download to work from. I'm running on Office 365.
I am trying to get the "Rate" and the "Days Billed" for each record. The amount is a function of Rate x Days Billed. The number of Days Billed max out with the total number of days in each month (i.e. November is 30 days max); these are also whole numbers.
I wrote this formula in E2:
=IFERROR(SMALL(IF(MOD($A2,ROW(INDIRECT("1:"&DAY(EOMONTH($B2,0)))))=0,ROW(INDIRECT("1:"&DAY(EOMONTH($B2,0))))),COLUMNS($E2:E2)),"")
In C2:
=MAX($E2:$R2)
In D2:
=A2/C2
When I drag across it spits out all the whole number divisors (Days Billed) that result in the Amount/Days Billed to also be a whole number. It is only getting me results for whole number Days Billed which also result in whole number Rates when dividing with the Amount. I want to include Rates that go to the hundredths place as well, not just whole numbers. (Rates often go to hundredths place)
For example, if the Amount is $4,832.40 in November the Rate should be $161.08 and the Days Billed should be 30 because 30 days is the max divisor of days and 161.08 is also divisible to the hundredths place.
Each amount basically has a whole number day multiplied by a rate that can be whole number or up to the hundredths place of denomination.
I may be overthinking this, but does anyone have any ideas of how to tweak my formula to achieve what I'm after? or even a better solution? It'd be ideal if I didn't have to have those helper columns either and it was encased in a single cell formula.
Thanks a ton,
spacej3di
Use LARGE instead of SMALL and multiply A1 by 100 and return the max:
=IFERROR(LARGE(IF(MOD($A2*100,ROW(INDIRECT("1:"&DAY(EOMONTH($B2,0)))))=0,ROW(INDIRECT("1:"&DAY(EOMONTH($B2,0))))),1),"")

How to create exponential growth in excel over a year

So I am trying to build an excel model where every month the numbers will increase exponentially to a point at the end of the year which is driven by annual expectations. Currently I have it divided by 12 and each year there are huge jumps over the previous making the chart/growth very jumpy. For illustration purposes, lets say for 2020 the desired number for the year is 12. In the current state, I would get 1 per month (12/12), however, what I want is for it to be growing gradually/exponentially, so for example 0.2, 0.5, 0.9 etc with December being the largest, and the sum for the entire year equaling 12. Then the next year (2021), starting in January, it would take into account the December 2020 number and grow from there again to the desired number (lets say total 24 for 2021) and so on. I'd love for it to have a more exponential / hockey stick-like growth.
What would be a good way to do this?
The function RRI can be used to find an interest rate which will give you a given target value. This can be used to find terms in a geometric series which have a given sum (which is what you seem to be asking for).
For example, say you want 12 exponentially increasing numbers which, when added to 100, gets you to 2000. Starting with 100, repeatedly multiply by (1 + RRI(12,100,2000)). To get the numbers that you want (which will be 12 numbers which sum to 1900) just calculate the difference each month:
I think the simplest way to solve this is by using Goal Seek. First you need to build a sheet like this:
You choose the starting value in January (B1) and every month is a constant growth rate (D1) bigger than the previous month. You also calculate the total sum at the bottom in B13.
Now you use goal seek to find the growth rate which makes the sum equal to 12:
The answer I get for a starting value of 0.1 is a growth rate of 1.376:

Excel Solver - Limit variable results to the tenths place only

I am trying to use excel solver to calculate a total number of hours by person when as well as some of their rates when I am provided with the Total Amount and I already know some of the rates.
Screenshot of worksheet
I know the following constraints will apply:
-Rates must integers divisible by 5
-Hours must be rounded to the tenth's place
-Rates will have a ">=" value depending on the worker
Thoughts on how to constrain the results to the variable cells this way so the rates will end in 5 or 0, and the hours will only stop at the tenth's place instead of returning 4.99663675 as a result?

Complicated excel equation with multiple conditions

I have a sheet that I use to calculate my taxes, deductions, and 401k based on a timesheet. It also calculates my PTO, sick, and comp days (I don't get overtime, when I work overtime I get that time back at the end of the year as extra paid days off). My issue is that with the timesheet, it's tough to calculate my sick days, all other times are hour for hour or based on the pay period. But with sick days I get a specific amount every year.
Basically, I get 10 days (80 hours) per year. So I take that 80 hours, divide it by 26, and that gives me how much sick time I get per pay period. Problem is, since I get a biweekly pay, that's not actually correct. So for example, this month I have 2 paychecks, I'd get .92 days of sick time, but I should actually get 1. On the 2 months out of the year where I have 3 paychecks I would get 1.38 days of sick time, which of course isn't correct either.
So the issue is I'm trying to figure out how to write a formula to give me the the correct number of days. Refer to the screenshot:
So basiclaly on G6, the formula takes the rolled over sick days from the previous year (G39) and adds the current sick time to it. It decides that by checking if the gross pay for that pay period is there, then multiplies that amount by the sick time accrual rate (G40) and divides that by 8 to give me the days.
But what I want to do is to check how many months have been filled out and return that. So in this example May has been completed, so it would return 1 day. Since September has 3 pay periods, you will need to have all three September paychecks filled out for it to increment from 4 to 5 (may, jun, jul, aug makes 4).
Any ideas? Everything I've tried to do this it just fails. Keep in mind that those dates are dynamic, next year when I change the start date for the tax year, the months that have 3 months will change to match the actual pay periods for that year. So this formula will need to actually be able to count that any month has 3 pay periods to advance the sick day count, otherwise to do it if there are only 2 that have been filled.
Attempt #2 to answer! >8(
The end equation to do this all in one cell is going to get ugly,but it will work. In order to explain this and basically how I developed it, I am going to break it down into parts. At the end the parts will be back substituted into the big equation.
The first thing I did was determine what row was last filled, or as per the comments what is the last row of column P that has a value greater than 0. In order to determine this I used the aggregate function in a temporary cell of T15 (yes, in the middle of your spreadsheet but it wont matter in the end):
=AGGREGATE(14,6,(P5:P30>0)*(ROW(P5:P30)-ROW(P5)+1),1)
To break this function down:
14 tells it we want to do an array type calculation sorting the array from largest to smallest.
6 tells it to ignore errors
(P5:P30>0) tells it to build a true (or 1) and false (or 0) array of cells greater than 0
(ROW(P5:P30)-ROW(P5)+1) generates an array listing row numbers
1 tells it to return the largest value in the array, if it was 2 the second largest.
Now the important thing here is what happens when you multiply the greater than 0 array with the row number array. You wind up getting only the row numbers where there is a value in P greater than 0. And when we sort that and ask for the largest number we get the last row you have completed. Something to work with.
So now we can look up the last date completed, do some checks to see if its the end of the month or not and figure out how many sick days. The ugly formula starts out as:
=IF(MONTH(INDEX(I5:I30,T15))=MONTH(INDEX(I5:I30,T15)+14),MONTH(INDEX(I5:I30,T15))-1,MONTH(INDEX(I5:I30,T15)))
The logic test here is to find our if the last filled out date and the date 14 days in the future are still the same month. If they are the same month, you are not at the end of the month yet and there for have only earn up to the previous month's number in sick days. As such this part will tell us the previous month's number os sick days:
MONTH(INDEX(I5:I30,T15))-1
Now if the date 14 days in the future is not the same month then we know the last entry for the month has been completed and therefore we have accrued that month's number in sick days and use basically the same formula:
MONTH(INDEX(I5:I30,T15))-1
well I can see we have called on cell T15 4 times just to determine if we are subtracting 1 or 0. While the IF formula may feel more inline with your thought process, we can rearrange things and still get the same results but shortening the formula, reducing the calls to cell t15 by 1 and dropping the IF all together. This only works because we are dealing with 1 and 0 which is also true and false.
=MONTH(INDEX(I5:I30,T15))-(MONTH(INDEX(I5:I30,T15))=MONTH(INDEX(I5:I30,T15)+14))
Now lets bypass that T15 calculation and back substitute it in to the month formula above to get:
=MONTH(INDEX(I5:I30,AGGREGATE(14,6,(P5:P30>0)*(ROW(P5:P30)-ROW(P5)+1),1)))-(MONTH(INDEX(I5:I30,AGGREGATE(14,6,(P5:P30>0)*(ROW(P5:P30)-ROW(P5)+1),1)))=MONTH(INDEX(I5:I30,AGGREGATE(14,6,(P5:P30>0)*(ROW(P5:P30)-ROW(P5)+1),1))+14))
Not done yet. That only tells you the number of days you have accrued this year. Not what you really want to know. you need to convert it to hours. It also need to be reduced by the number of sick days used. The following need to be added to the big ugly above:
*8 for 8 sick hours to a sick day
-sum($L$5:$L$30) to account for sick time used
this results in:
=(MONTH(INDEX(I5:I30,AGGREGATE(14,6,(P5:P30>0)*(ROW(P5:P30)-ROW(P5)+1),1)))-(MONTH(INDEX(I5:I30,AGGREGATE(14,6,(P5:P30>0)*(ROW(P5:P30)-ROW(P5)+1),1)))=MONTH(INDEX(I5:I30,AGGREGATE(14,6,(P5:P30>0)*(ROW(P5:P30)-ROW(P5)+1),1))+14)))*8-sum($L$5:$L$30)
Now I did notice during testing that if no entries are in the spreadsheet, then the row of the last entry become 0 and this is simply not acceptable as it causes some strange results. So we will wrap this whole formula in a small error catcher to make sure 0 is the results when no payperiods have been completed.
=if(sum(P5:P30)=0,0,(MONTH(INDEX(I5:I30,AGGREGATE(14,6,(P5:P30>0)*(ROW(P5:P30)-ROW(P5)+1),1)))-(MONTH(INDEX(I5:I30,AGGREGATE(14,6,(P5:P30>0)*(ROW(P5:P30)-ROW(P5)+1),1)))=MONTH(INDEX(I5:I30,AGGREGATE(14,6,(P5:P30>0)*(ROW(P5:P30)-ROW(P5)+1),1))+14)))*8-sum($L$5:$L$30))
The icing on the cake is adding on the accrued sick days from the previous year. Since I am not sure how the sick rate and sick start work together I will leave that calculation up to you and simply let you know that whatever number gets carried over from the previous year, simply add it to the above formula after the very last ).
Here is my test bed showing proof of concept:
WARNING: This method ##WILL## produce false results for a pay period is =0 before the last date with a pay period >0 see example below:

Complicated formula required to work out costs including multiple discounts

I'm looking to compute and show individual row totals and a Grand Total. I just need the formulae to put in the boxes so the calculation is automatic but the problem is the calculations are a little complicated...
I'm using data validation to select the day type. This is what I think I need:
Assign a price to the day type (either Standard day = £23 or Extended day = £26).
Apply a volume discount where appropriate. If Jack is attending all week (5 days) and the day type is the same for all (all Standard or all Extended), the total cost is £100 (or £120)
Else the total number of days needs to be added up for Jack. (Number of days for each ‘day type’) and priced up.
For his siblings after the first, as above but apply an additional discount of 15%.
The grand total then needs to show at the bottom.
Well, it is not the best of data layouts but this may serve, in L6 and copied down to L13:
=IF(OR(A6="Brother",A6="Sister"),0.85* IF(COUNTIF(B6:F6,"Standard day")=5,100,IF(COUNTIF(B6:F6,"Extended day")=5,120,COUNTIF(B6:F6,"Standard day")*23+COUNTIF(B6:F6,"Extended day")*26)), IF(COUNTIF(B6:F6,"Standard day")=5,100,IF(COUNTIF(B6:F6,"Extended day")=5,120,COUNTIF(B6:F6,"Standard day")*23+COUNTIF(B6:F6,"Extended day")*26)))
and =SUM(L1:L16) in D16.
It would be better practice not to hard code the daily rates/discount, but extracting these from C1:D2 would have increased the length of the formula further.
Note also the result is not £429.95 (you may have changed your example after doing your calculations).

Resources