I 'd like to lookup in which period a date falls. Every period has its onwn name.
In my first sheet I have a list of dates:
4/03/2019
15/01/2019
15/01/2019
20/02/2019
11/02/2019
11/02/2019
In an other sheet I have the name with the corresponsing start and end date:
NAME START END
A1 12/01/2019 22/01/2019
A2 23/01/2019 8/02/2019
B 9/02/2019 13/02/2019
C1 14/02/2019 1/03/2019
C2 2/03/2019 5/03/2019
C3 6/03/2019 15/03/2019
I would like to have the following result
4/03/2019 C2
15/01/2019 A1
15/01/2019 A1
20/02/2019 C1
11/02/2019 B
11/02/2019 B
Use INDEX/MATCH Like this:
=INDEX(E:E,MATCH(A1,F:F))
You can try this:
I suppose that your dates are in a sheet named "dates"
And you have your data in other Sheet
You can easly get your result with the following formula:
=INDEX(Sheet12!A:C,MATCH(dates!A2,Sheet12!B:B,1),1)
I hope this helps!!!
You don't even need the end date, as your dates are increasing
=VLOOKUP(D1,$A$1:$B$6,2,TRUE)
where D1 is the date you're matching A is the start date and B your codes
What about using INDEX & MATCH? Example below:
[Assuming your first set of data is in column A, and the formula would be in column B on Sheet1, and your second table is columns A:C in Sheet2. So the example in your third table would have "C2" in column B]
Note: You'll need to use Ctrl+Shift+Enter to enter as an array formula.
=INDEX(Sheet2!$A$2:$A$7,MATCH($A2,IF($A2>=Sheet2!$B$2:$B$7,IF($A2<=Sheet2!$C$2:$C$7,$A2)),0))
Are the date ranges set to expand further beyond a static list or are they set. Because if they are set i would be tempted to do a nested IF statement. I can explain if this is the case.
IF("date cell"<=latest date,code,If("date cell"<= next latest, If( repeat until happy
Related
I am currently trying to run an excel function that runs the logic that if the cell that has date X is greater than date 2023-01-01 then run an XLookup function. If it is not then do not run it.
Here's what I tried below:
=IF(table2!N5>DATE(2023,1,1),XLOOKUP(A2,'Table2'!A:A,'Table2'!B:B),"FALSE")
N5 has the date 2022-12-01. The rest is just a standard xlookup function that would run if cell N5 is greater than the date 2023-01-01.
Data for the Xlookup below:
Table 1 : This table provides the lookup value A1.
A B C
1 Position Classification Full Name
2 111111 IT 04 John Smith
Table 2 : This table provides the lookup array being A:A and the return array being B:B
A B C D
1 Employment Position CC Valid From Valid To
2 111111 8888888 2022-10-01 2023-03-31
As posted in comments, I will suggest you use a cell reference, so it becomes more dynamic to use, instead of hard coding within a formula,
• instead of this
=IF(N5>0+"2023-01-01",XLOOKUP(E3,H:H,J:J),"FALSE"))
• Use a cell reference, let's say cell A1 = 2023-01-01
=IF(N5>A1,XLOOKUP(E3,H:H,J:J),"FALSE"))
So the above helps you in changing the cell A1 values whenever you need instead of bothering the formula each time for a change.
I would advise you to use the DATE() function, like this:
= IF(A1>DATE(2023,1,1), ...)
I have an Excel file in which some columns. The Excel is my bank account.
The D column is date, and not just for one day,its the days of a week.
I want to some all columns in that has the same date, and insert it in new cell.ex : for a week i should have 7 sum.
Here is some possible data from the sheet.
date(Column D) Money(Column K) Sum of same date(Column N)
1396/1/1 2300
1396/1/1 1000 3300 // some of the same date
1396/1/2 1200
1396/1/2 320 1550 // some of the same date
It is possible with Excel functions? Does I need a subroutin?
In L2 try,
=IF(ROW()=MATCH(D2, D:D), SUMIFS(K:K, D:D, D2), TEXT(,))
Fill down.
Use this formula:
=IF(D2<>D3,SUMIF(D:D,D2,K:K),"")
Then copy down
Hey you need to work with Sumif or SUMIFS and your Formula should like,
SUMIFS(D2:D10, C2:C10,">="&TODAY()-7, C2:C10,"<="&TODAY())
Or it should be like,
=SUMIFS(D2:D10, C2:C10,">="&A2, C2:C10,"<="&A3)
Or
=SUMIF(D2:D10, C2:C10,">="&TODAY())
NB: Sum Range is D2:D10 & C2:C10 is Criteria range.
In 2nd example A2 & A3 Cells holds Date value.
Suppose your Dates are in Col A & you want to Sum values in Column B, so instead of Sumif you can use this,
C2=SUMPRODUCT(--(MONTH(A$2:A$10)=ROW()-1),--(B$2:B$10))
NB: MONTH function will pull the Month value from A2 and add with corresponding Cell value in B, drag the formula below.
Here is my excel looks
Column A Column B
1/1/2016
2/1/2016
3/1/2016
4/1/2016
5/1/2016
.
.
.
31/1/2016 1000
Now I will be referring one of the date in this month on another sheet and I would like to pull Column B value corresponding to last date on each month. There wont be any value till last date on column B.
Any hint to do this ?
First step is to make the condition:
=IF(A1=EOMONTH(A1,0),B1,"")
Note: if date in A1 is really the end of its month, it takes result from B1
Second step is to combine it with Vlookup. I assume that you would input some date in column C:
=IF(C1=EOMONTH(A1,0),VLOOKUP(C1,$A$1:$B$1000,2,FALSE),"")
Third step is... you can change the formula if your input is in another sheet. For the example: the data are in "sheet1" and the date input are in column C at "sheet2":
=IF(C1=EOMONTH(Sheet1!A1,0),VLOOKUP(C1,Sheet1!$A$1:$B$1000,2,FALSE),"")
Hope it'll help.
I am trying to create an excel formula which will count all of the occurrences of the word 'Yes' in my column K where the year of the date in column B is '2014'.
Column B Column K
01/02/2014 Yes
03/04/2014 No
06/01/2014 Yes
08/02/2015 Yes
So I know how to get the year from my date in column b
=YEAR(B:B)
But now I want to combine this and put it into a countif formula which will count all of the yes's in my column k where the year in column b is 2014.
here's what I've tried to put together:
=COUNTIF(K:K="Yes",YEAR(A:A)=2014))
This doesn't work, please can someone show me where I'm going wrong.
Try this:
=SUMPRODUCT(--(YEAR($A$2:$A$5)=2014),--($B$2:$B$5="Yes"))
To make it more dynamic, i.e.: get the criteria from the matching row data, change the formula to this:
=SUMPRODUCT(--(YEAR($A$2:$A$5)=YEAR(A2)),--($B$2:$B$5=B2))
EDIT:
Maybe this is what we need, paste below formula to C2:
=SUMPRODUCT(--(YEAR($E$2:$E$5)=A2),--($F$2:$F$5=B2))
Maybe not the most elegant solution, but this would work :
Create 3rd column with formula : =YEAR(A2) & B2
And to get your count use : =COUNTIF(C2:C5; "2014Yes")
I need to match data in column A2 and so on in sheet 1 to data in column A2 and so on in sheet 2. If the data in column A of sheet 1 and sheet 2 match I need the data in column B & C of sheet 2 to replace data in column B & C of sheet 1. I know VERY little about doing this kind of stuff so any help would be GREATLY appreciated!
SHEET 1
A B C
2 12345 5.35 9.95
3 15874 4.22 10.99
4 11111 2.24 5.99
5 98745 5.33 9.95
6 88552 4.24 8.95
SHEET 2
A B C
2 11111 2.09 5.79
3 12345 5.11 9.89
4 88552 4.01 8.79
NEED SHEET 1 to change to
A B C
2 12345 5.11 9.89
3 15874 4.22 10.99
4 11111 2.09 5.79
5 98745 5.33 9.95
6 88552 4.01 8.79
On a third sheet use these functions
column a ='sheet1'!a2
column b =if('sheet1'!b2='sheet2'!b2,'sheet2'!b2,'sheet1'!b2)
column c =if('sheet1'!c2='sheet2'!c2,'sheet2'!c2,'sheet1'!c2)
Copy sheet3 and paste the values into sheet1.
This should work unless column a does match. or if you need to do this dynamically. If column a doesn't match some vlookups can be thrown in.
I your data does match in column a your formulas could look something like this.
column a ='sheet1'!a2
column b =if(not(iserror(vlookup(a2,'sheet2'!a:c,2,false))),vlookup(a2,'sheet2'!a:c,2,false),vlookup(a2,'sheet1'!a:c,2,false))
column c =if(not(iserror(vlookup(a2,'sheet2'!a:c,3,false))),vlookup(a2,'sheet2'!a:c,3,false),vlookup(a2,'sheet1'!a:c,3,false))
this is too much to put in a comment so I'm putting it in answer.
The way I under stand is, since sheet1 has more data, you only want to be doing this comparison when sheet1 and 2 both have data on the row. so If sheet1 has data in rows 1 - 100, and sheet2 has data in rows 1 to 50, you only want to be doing this comparison for the first 50 rows in sheet1 right?
So, rather than copying and pasting formulas, what you can do is, in sheet1, find an unused column. go to the first row. in the formula box, type: "=if(" without the quotes. now, select the first cell to compare, according to your example you'd select sheet1, A2. then type "=" without quotes. then select the second cell you want to compare - in your example, sheet2, A2. then type "," without quotes. then select the cell from which you want the data if the first 2 cells are equal. in your example, sheet2 B2. then type "," without quotes, then select the cell with the data to use if the first 2 cells are not equal. in your example, sheet1 b2. then type ")" without the quotes.
so using your example, the function would look similar to how bigtree had it: =if('sheet1'!A2='sheet2'!A2,'sheet2'!b2,'sheet1'!b2)
so, this will compare sheet1 cell A2 with sheet2 A2 and if they are equal, the cell you put the formula in will the have the value of sheet2 b2, and if they are not equal, the cell with this formula will have the value of sheet1 B2. then, drag this formula down for however many rows you want, and the formula will adjust automatically for each row. you'll see the numbers increase. then, select the column with the formulas, right click and select copy, then right click and go to paste special, and click values. this will make it so the column contains only the values, not the formulas, now you can paste this data in column B sheet 1.
you can reuse this formula for whatever columns, just follow the steps.
HTH, good luck!