EXCEL FORMULA FOR DATES - excel-formula

I just want to ask an excel formula for this.
If an employee exceeds one year of employment he will have a free uniform
If he was hired last October 1, 2015 and he requests for new uniform this October 22, 2016 then he should have free uniform.
10/1/2015 - 10/22/2016 = "Can Avail Free Uniform" or "Cannot Avail!"
I just want the two optional answers to reflect using an excel formula.
Thanks

If I would create a formula like this:
I would use 4 cell columns:
Date Hired,Date Request,Years of Service,isAvail
On my Years of Service, I would use DateDif Function,
Where =(DateDif('cella','cellb',"m")/12) in order to achieve a year.
Then on isAvail column, I will use =IIF('cellc >= 1', "Can Avail","Cannot Avail")
See if it helps.

I would use these four columns
and use the following formula in D2:
=IF(AND((C2-A2)/365>=1,(C2-B2)/365>=1),"Can avail free uniform","Cannot avail")
This checks to see of the time since date of hire AND the time since the previous request is more than 1 year and returns "Can avail free uniform" if both equals ore are greater than 1, and returns "Cannot avail" if one of them is less than 1.

Related

Is there a way to find the time between 2 dates after subtracting in excel?

I am given this task to complete
"What is the average time for a project to go to 3-Offered per year for the years 2016, 2017, and 2018? Use the formula # Days = [Date Offered] - [Start Date].
Only projects where [Project Template] = "Pre-Approval" will have an offered date, no need to include Fast Track projects in the data."
my current function I am trying to use is
=AVERAGE(IF((B:B="Pre-Approval")*(C:C="3-Offered")*(YEAR(D:D)=2016),E:E-D:D)) but I am getting the #VALUE! and I'm not sure why.
I will link a screenshot of some of the data used for this task.
[Column D is the start date and Column E is the Offered Date]
I think it is easier if you break down the problem into smaller pieces.
First, I would separate the years from the offered date. On a different column, e.g. Year, I would apply =YEAR() for every item in your Offered Date column.
Second, I would take another column, call it Diff, and apply =OfferedDate-StartDate.
Then, for each individual year I would apply =AVERAGEIFS(diff_column_range, year_column_range, "3-Offered", year_column, required_year)
I have an example for you here: https://1drv.ms/x/s!AhMbe-MPmuFCggjutWepn-QtMri4?e=CxpTCW
Let me know if this works for you.
Cheers!

Excel formula to split an amount per year depending on expenditure days within a date range

I am in the process of building a formula to split a total cost (in column J) based on start and end expenditure periods that can vary from 2021 to 2031. Based on the days between the expenditure period dates (column M), I managed to work out to split the cost using the formulas below up to 2023 but it is not consistent and at times incorrect.
In cell P5 I have the following formula. For year 2021, I seem to get the correct split result.
=IF($K5>AS5,0,$J5/$M5*(AS5-$K5))
In cell Q5, I have the following formula. For year 2022, I seem to get the correct spit as well
=MIN(IF(SUM($N5:P5)>=$J5,0,IF($L5>=AS5,$J5/$M5*(AS5-AR5),$J5/$M5*($L5-MAX(AR5,$K5)))),K5)
However, I don't get the right result in cell Q6 which has the same formula but different dates
=MIN(IF(SUM($N6:P6)>=$J6,0,IF($L6>=AS6,$J6/$M6*(AS6-AR6),$J6/$M6*($L6-MAX(AR6,$K6)))),K6)
Cell R6 shouldn't return any result because it is out of date range. This is where things get mixed up.
Note that from column AR to BC, it is all year end dates from 2020 to 2031 as shown below.
Is there a better way to tackle this sort of formula as I seem to get dragged into a long and unreliable way of doing this.
Here single function(♣) that will create a series of pro-rata multipliers (of appropriate length) for any given start/end date:
EDIT: see end of soln for extended version per OP comment to original soln...
SINGLE FUNCTION
=J11*(LET(dates,EDATE(DATE(YEAR($K11),1,1),12*(SEQUENCE(1,YEAR($L11)-YEAR($K11)+2,1))),IF(dates<K11,K11,IF(dates<L11,dates,L11)))-LET(dates,EDATE(DATE(YEAR($K11)-1,1,1),12*(SEQUENCE(1,YEAR($L11)-YEAR($K11)+2,1))),IF(dates<K11,K11,IF(dates<L11,dates,L11))))/(L11-K11)
It may appear somewhat unwieldy in length, but it is far more robust (and concise) compared to the combination of steps/series you have created. What's more, it returns the precise answer RE: pro-rata payments and is guarenteed to never over/under-run RE: total payment (by design).
BREAK-DOWN
Comprises 3 distinct parts (some of which are similar in pattern/formation):
1] First part - create a series (array) of years spanning start-end dates:
=LET(dates,EDATE(DATE(YEAR($K5)-1,1,1),12*(SEQUENCE(1,YEAR($L5)-YEAR($K5)+2,1))),IF(dates<K5,K5,IF(dates<L5,dates,L5)))
Thanks to the lovely Spill functionality the new Office 365 variant Excel boasts, you never have to worry about how many years are required -- so long as you have the space to the right of this workbook (would be unusual otherwise - assuming you start in column O and clear any content to the right of this, you'd need an end date beyond the year 2557 (26th century) to run out of columns! ☺
2] Second part is merely a replica of the firs series, albeit shifted to the right 'once' (so starts with the 2nd element in the 1st series):
=LET(dates,EDATE(DATE(YEAR($K5),1,1),12*(SEQUENCE(1,YEAR($L5)-YEAR($K5)+2,1))),IF(dates<K5,K5,IF(dates<L5,dates,L5)))
3] Third part - you have the basic ingredients from parts 1 and 2 to complete the required task easily: simply deduct series 2 from 1 (giving days between successive dates in series 1 - i.e. days for each year between start and end dates), divide by total days (to yield pro-rata multipliers), and then multiply these by the total £amount and voila - you have your series!
=J5*(O6#-O5#)/(M5)
♣ Caveat(s) - assuming you have Office 365 compatible version of Excel (which is quite common nowadays)
*EDIT - EXTENDED VERSION
Given above, the following extends this to align monetary results (1st table, o11:w21) within respective calendar period columns (spanning the entire period in question).
This soln:
Determines header row based upon the number of columns & corresponding calender periods (financial yrs commencing 1/1) as an array function (i.e. dynamic range)
Utilises a modified version of the eq. provided for dates arrage (refer: "First Part", original soln)
Comment - same caveats as before - i.e. Office 365 etc.
Screenshot(s)/here refers:
DATES (HEADER) - Y10 (array)
=LET(y_,MIN(K11:K21),x_,MAX(L11:L21),EDATE(DATE(YEAR(y_)-1,1,1),12*(SEQUENCE(1,YEAR(x_)-YEAR(y_)+2,1))))
Comment - enter once within single cell Y10 - i.e. as an array function with Spill to right
ALIGNED/SHIFTED FINANCIALS - Y11:Y21 (each cell in col is an array)
=IFERROR(IF(Y$10#<EDATE(K11,-12),"",IF(Y$10#>EDATE(L11,12),"",INDEX(O11#,1,MATCH(Y$10#,EDATE(DATE(YEAR($K11)-1,1,1),12*(SEQUENCE(1,YEAR($L11)-YEAR($K11)+2,1))),0)))),"")
Comment - enter this as an array fn. (#SPILL! to the right) in each cell within column Y (can drag this function down Y11:Y21 as required)

How to reference one value to various cells, depending on a date?

Please have a look at the picture I attached, it'll make understanding my problem easier because it's hard to describe.
In the first table, I have capacity data for a product. The capacity changes by the date indicated in the column, i.e. from July 2017 the capacity would be 56, from December 2018 78, and from October 2019 99. The reason why I don't write down the capacity for every month is that I want to save columns.
In the second table, I have every month. I want to reference the correct capacity for each month, e.g. it would be 56 for every month until December 2018.
I have been considering an =INDEX function, but it seems to complex for that. Is there a way to reference like this without using VBA? Would the VBA solution be simple? Or am I forced to write a column for every month's capacity in the first table? Thank you!
https://i.imgur.com/mRoBtTo.png
You can simply use several IF statements to compare the month in your column with the months given in your first table, and put the value of the correponding month.
Let's admit your first row is 1 and first column is A, it should give something like:
= IF(D7>=$F$2; $F$3; IF(D7 >= $E$2; $E$3; IF(D7 >= $D$2; $D$3; "")))
I dont see you columns and rows so i hope you will change them correctly on this formula:
=HLOOKUP(C111,$C$106:$P$107,2,TRUE)
C111 is the cell above your red row.
$C$106:$P$107 is the tableof capacities, i know it is bigger then the current one so you see you can add more columns.
2 is the row number from the capacity table.
true is becouse you dont want it to be the exact value it will take the previews in hte order of items
Both previous answers work perfectly, but I would go this way-
You don't actually need an if to find the previous capacity. you can simply use the approximate match (similar to the hlookup answer) in an index formula
=+INDEX($B$4:$E$5,MATCH($B$9,$B$4:$B$5,0),MATCH(C9,$B$4:$E$4,1))
The product $B$9 matches exact (0), but the date C9 is bigger than or equal (1).
$B$4:$E$5 is the source of capacity and
C9:AF9 the date timeline
Final advantage would be that you can have several products to index, not only a single one.
Could you please try the below formula and provide feedback please?
=IF(AND(D8>=D2,D8<E2),"56",IF(AND(D8>=E2,D8<F2),"78",IF(D8>=F2,"99")))

Duplicate in Excel

I am having an issue with excel formula which I am unable to write. I have 2 columns Interest rate and Maturity. Through pivot I get the data year wise. Problem is that when there are multiple values for same year, pivot should keep value as blank and I also need to add a formula that checks if interest rate for particular year remains same like in below case of 2021. If that stands true then I need to populate value. If you provide me a code for VBA or formula then it will be a big help !!!
Int Rate Maturity
2.14% 2020
4.08% 2023
3.82% 2024
3.19% 2026
3.93% 2027
2.11% 2021
2.11% 2021
2.79% 2019
2.99% 2023
This is how I solved it:
Start with a simple COUNTIF to count whether a year is duplicate or not.
Then create a (hidden) column that concatenates the year and its interest rate by using CONCAT.
Now perform the same COUNTIF on the column containing the concatenated data. By testing this column, you are testing the uniqueness of a combination "year-interest rate".
Use a simple IF. If the number you obtained in (1) is equal to the number obtained in (3) it means the year/interest rate combination is valid. If the numbers are not equal, it means there are at least 2 conflicting entries.

CountIfs with Multiple Criteria?

I have a table like this:
Date Paid Days Late Date Paid Days Late Date Paid Days Late Date Paid Days Late Date Paid Days Late Date Paid Days Late
Utilities Admin Utilities Admin Utilities Admin
Company January January January January February February February February March March March March
Wayne Enterprises 2/15/2016 5 10-Feb 0 3/11/2016 1 4/15/2016 5 4/25/2016 15
Stark Industries 2/12/2016 3 2/8/2016 0 3/19/2016 10 3/8/2016 0 4/15/2016 5 4/1/2016 0
(I suggest though looking at the screenshot to see how it's laid out, as the pasting into here isn't very pretty, any tips? Here's a link to this on Google Spreadsheets).
How can I, in N4, create a formula that will count the number of months what have a late report (defined as any "Days Late" over 0). Obviously, I can do this:
=COUNTIFS(B1:M1,"Days Late",B4:M4,">0"), which returns 4.
For Wayne Enterprises, in March, both Utilities and Admin were paid late. However, this should only count as 1 month. How can I somehow add to my CountIfs() a statement that is like "if two values in the same month are greater than 0, treat as ONE month"?
I tried also doing something like:
=COUNTIFS(B1:M1,"Days Late",B4:M4,">0")/COUNTIFS(B1:M1,"Days Late",B4:M4,">0")+1
But that doesn't quite do the trick either. Thanks for any ideas. (Of course, if CountIfs() isn't the best way, I'm open to any other formulas! I have a sneaking suspicion SumProduct() might be an alternative) I'd prefer a formula solution over VBA, but if absolutely necessary, we can do a UDF perhaps.
Edit: I could create yet another helper column that compares a single month's Utilities and Admin, and if one or both are late, put 1, then just Countif() that column has 1 in it...but I'd rather not keep creating columns if I can help it, as I'll be doing this for 12 months.
Use this Array formula:
=SUM(IF(($B4:$M4>0)*($B$1:$M$1="Days Late"),1/COUNTIFS($B$3:$M$3,$B$3:$M$3,$B4:$M4,">0",$B$1:$M$1,"Days Late")))
Being an array formula it must be confirmed with Ctrl-Shift-Enter when exiting edit mode. If done properly excel will put {} around the formula.
As per your new data use this:
=SUM(IF(($B5:$BI5>0)*($B$1:$BI$1="Days past 10th of Following Month"),1/COUNTIFS($B$3:$BI$3,$B$3:$BI$3,$B5:$BI5,">0",$B$1:$BI$1,"Days past 10th of Following Month")))
The helper row of months in row 4 is not needed.
EDIT #2
My bad I forgot that when using formulas that return "" will cause an error so lets put in a check for that:
=SUM(IF(($B5:$BI5<>"")*($B5:$BI5>0)*($B$1:$BI$1=$AS$1),1/COUNTIFS($B$3:$BI$3,$B$3:$BI$3,$B5:$BI5,">0",$B$1:$BI$1,$AS$1)))

Resources