How match multiple column values and extract corresponding cell values in Excel - excel

Sheet 1
Cust Visit DATE TIME
201 Day 1 11-Jul-17 11:15
201 Day 1 11-Jul-17 11:18
201 Day 1 11-Jul-17 11:20
201 Day 3 13-Jul-17 11:30
201 Day 3 13-Jul-17 11:32
201 Day 3 13-Jul-17 11:34
201 Day 7 17-Jul-17 11:20
201 Day 7 17-Jul-17 11:22
201 Day 7 17-Jul-17 11:24
201 Day 10 20-Jul-17 11:30
201 Day 10 20-Jul-17 11:32
201 Day 10 20-Jul-17 11:34
201 Day 14 24-Jul-17 11:15
201 Day 14 24-Jul-17 11:17
201 Day 14 24-Jul-17 11:19
202 Day 1 11-Jul-17 11:20
202 Day 1 11-Jul-17 11:22
................
.............
Sheet 2
RefC RVisit RDATE RefTIME
201 Day 1 11-Jul-17 9:30
201 Day 3 13-Jul-17 9:30
201 Day 7 17-Jul-17 9:30
201 Day 10 20-Jul-17 9:30
201 Day 14 24-Jul-17 9:30
202 Day 1 11-Jul-17 9:35
202 Day 3 13-Jul-17 9:35
...............
.....
First set of columns in excel show customer ID visit date and time for their survey participation.
The second set of columns shows the same Customer IDs shared by reference customers and similar details. Both are in the same sheet of excel.
We are to compare the time difference between reference customers and current customers of their visits. i.e. I want the values in RefTime column lined up next to the TIME column when refc matches Cust and Rvisit matches visit and date matches Rdate. The visits can be 3 per day or 2, it may vary.
I am unsure of how to approach this using formulas (INDEX & MATCH ?), and i am new to excel. Any help or intro to help me achieve this is appreciated.
Thanks !
Sorry for not being clear..For ex. I want the Reftime below 9.30 for Refc # 201
RefC RVisit RDATE RefTIME
201 Day 1 11-Jul-17 9:30
to appear next to TIME column for the first 3 rows of below as all details of above match (cust # wtih RefC , visit with Rvisit and date with Rdate).
Cust Visit DATE TIME
201 Day 1 11-Jul-17 11:15 9:30
201 Day 1 11-Jul-17 11:18 9:30
201 Day 1 11-Jul-17 11:20 9:30

It is still unclear what you want. I think you want a VLOOKUP but on more than one key. You can add a column in the Sheet2 to the left of the current columns - Assuming the RefC R Visit is Col B:
in Col 1, copy down =B1&B2 and then you can reference this column (and its subsequent columns) in a concatenated VLOOKUP: in the cell in SHeet1 where you want the result - assuming Cust Visit is column A, you put in, say Col E, =VLOOKUP(A2&B2,Sheet2!$A$2:$E$10000, 3, False)
The dollar anchors are important on the second parameter. The 3 in the third parameter says match column C, the False means look for exact matches. Wrap it in an IFERROR of IF(ISNA()) if you want to avoid non-found record errors.

Related

Excel function to dynamically SUM UP data based on matching rows and columns

I have a table with metrics shown as rows and month shown as columns.
Example is below:
Quarter
2022-01-01
2022-01-01
2022-01-01
2022-04-01
2022-04-01
2022-04-01
2022-07-01
2022-07-01
2022-07-01
2022-10-01
2022-10-01
2022-10-01
Month
2022-01-01
2022-02-01
2022-03-01
2022-04-01
2022-05-01
2022-06-01
2022-07-01
2022-08-01
2022-09-01
2022-10-01
2022-11-01
2022-12-01
Metrics
Jan 2022
Feb 2022
Mar 2022
Apr 2022
May 2022
Jun 2022
Jul 2022
Aug 2022
Sep 2022
Oct 2022
Nov 2022
Dec 2022
Revenue
1000
1000
1000
500
500
500
100
100
100
0
0
0
Cost
10
10
10
10
10
10
20
20
20
0
5
10
I want to have a dynamic summary table of quarterly data. I can use sumifs and look up the quarter month using this function:
SUMIFS([Value row range],[Quarter range],[Quarter wanted])
However, i still have to manually select the correct value row range to sum. Is it possible to select the entire table and then match the correct row based on matching labels (metric in this case)?
Insert Report Month
Dec-22
Last 3 quarter report
Metrics
Q2 2022
Q3 2022
Q4 2022
Revenue
1500
300
0
Cost
30
60
15
I'm aware of the index & match function, but it only looks for the first match and does not sum up all months in the same quarter.
Thanks for helping!
Excel 365 for MAC should have the BYCOL function,
Given:
Your data table is a Table named Metrics
Report_Month is a Named Range containing a "real date" in the month of the final month of the desired quarter.
The following formula will return your output and will adjust as you add columns to the data table.
A11: =Metrics[[#All],[Metrics]]
B11: =LET(x,EDATE(Report_Month,SEQUENCE(,3,-6,3)),TEXT(MONTH(x)/3,"\Q0 ") & YEAR(x))
B12: =BYCOL(XLOOKUP(TEXT(DATE(YEAR(Report_Month),MONTH(Report_Month)-9+SEQUENCE(3,,1,1)+SEQUENCE(,3,0,3),1),"mmm-yy"),Metrics[#Headers],INDEX(Metrics,XMATCH(A12,Metrics[Metrics]),0)),LAMBDA(arr,SUM(arr)))
Select B12 and fill down as far as needed.
Notes
DATE(YEAR(Report_Month),MONTH(Report_Month)-9+SEQUENCE(3,,1,1)+SEQUENCE(,3,0,3),1)
creates a matrix of the previous nine month starting dates with each column consisting of a given quarter:
So for 12/1/2022 =>
The TEXT function then formats the same as the column headers in the Metrics table.
XLOOKUP will then return the appropriate columns from the table into that matrix, and using the BYCOL allows us to SUM by column which is the relevant quarter.

Time manipulations

Hello I have to count how many people were scheduled on each hour in excel so I transformed starting and ending data/time to only contain time and basing on it I tried to substract these two information but I only get an hour then but what I need is the hours to be like this:
instead
starting on 9:00
ending on 17:00
this
9:00
10:00
11:00
12:00
13:00
14:00
15:00
16:00
17:00
to count every hour that employee was at work. But I don't know how :(
Or is there a better way of doing that?
Assuming your table looks something like this:
Person
Start
End
09:00
10:00
11:00
12:00
13:00
14:00
15:00
Alice
08:35
16:35
1
1
1
1
1
1
1
Bob
09:35
17:35
0
1
1
1
1
1
1
Carl
10:35
18:35
0
0
1
1
1
1
1
Dan
11:35
19:35
0
0
0
1
1
1
1
Ed
12:35
20:35
0
0
0
0
1
1
1
Total present
1
2
3
4
5
5
5
You can compute the entries 0 or 1 in each cell under the times using the formula
=IF(AND((E$4>$C6);(E$4<=$D6));1;0)
In the formula, E$4 is a reference to the column header, e.g. "9:00", $C6 and $D6 are references to the start and end times of the person. They are defined using partial absolute references ($) so the same formula can be copied and pasted in all the cells.
The result will be 1 if the person was present at that time and 0 if not.
The "Total present" formulas just sum up the 1's and 0's in the column.

Excel indexmatch, vlookup

I have a holiday calendar for several years in one table. Can anyone help – How to arrange this data by week and show holiday against week? I want to reference this data in other worksheets and hence arranging this way will help me to use formulae on other sheets. I want the data to be: col A having week numbers and column B showing holiday for year 1, col. C showing holiday for year 2, etc.
Fiscal Week
2015 2014 2013 2012
Valentine's Day 2 2 2 3
President's Day 3 3 3 4
St. Patrick's Day 7 7 7 7
Easter 10 12 9 11
Mother's Day 15 15 15 16
Memorial Day 17 17 17 18
Flag Day 20 19 19 20
Father's Day 21 20 20 21
Independence Day 22 22 22 23
Labor Day 32 31 31 32
Columbus Day 37 37 37 37
Thanksgiving 43 43 43 43
Christmas 47 47 47 48
New Year's Day 48 48 48 49
ML King Day 51 51 51 52
It's not too clear what year 1 is, so I'm going to assume that's 2015, and year 2 is 2014, etc.
Here's how you could set it up, if I understand correctly. Use this index/match formula (psuedo-formula):
=Iferror(Index([holiday names range],match([week number],[2015's week numbers in your table],0)),"")
It looks like this:
(=IFERROR(INDEX($A$3:$A$17,MATCH($H3,B$3:B$17,0)),""), in the cell next to the week numbers)
You can then drag the formula over, and the matching group (in above picture, B3:B17) will "slide over" as you drag the formula over.

Error in COUNTIFS function

I want to count how many vehicles are delayed more than 4 min on a given day according to a given departure (let's assume from 00:00 to 05:00).
This is a sample of the data:
A B C D
1 Line Day Departure Delayed (sec)
2 11 Weekday 02:30:00 120
3 11 Weekday 03:40:00 500
4 22 Weekday 01:45:00 10
5 44 Weekday 06:44:00 1000
6 55 Weekday 04:35:00 145
7 111 Saturday 14:40:00 450
8 111 Saturday 04:20:00 300
9 111 Saturday 20:20:00 220
10 111 Saturday 07:00:00 125
11 333 Sunday 09:15:00 700
I used a "TÆL.HVISER" function (Danish) or COUNT.IFS function to count the vehicles:
=TÆL.HVISER(A2:A11;"11";B2:B11;"Weekday";C2:C11;00:00:00>C2:C11>05:00:00;D2:D11;">240")
But it is not working. When I break this restriction into four restrictions, the individual restrictions are working but when I combine them it's not working.
I've laid out your data according to how I read your sample formula.
    
The EN-US formula in G4 is,
=COUNTIFS($A$2:$A$11, G$3, $B$2:$B$11, $F4, $C$2:$C$11, ">="&TIME(0, 0, 0), $C$2:$C$11, "<="&TIME(5, 0, 0), $D$2:$D$11, ">="&240)
Fill both right and down. I've use the TIME function so that a) real times could be referenced and b) it makes it easier to set to new values.
TÆL.HVISER, funktionen
Funktionen TID
It is the part
00:00:00>C2:C11>05:00:00
if you change it to two criteria like this
C2:C11;">00:00:00";C2:C11;"<05:00:00"
it will work. Here is the full formula:
=COUNTIFS(A2:A11;"11";B2:B11;"Weekday";C2:C11;">00:00:00";C2:C11;"<05:00:00";D2:D11;">240")

Return values in same row by searching different column

Given data like this:
A B C D
1 MAX. Time MIN. Time
2 140 08:00 100 01:00
3 150 15:00 50 02:00
4 130 17:00 80 03:00
5 120 22:00 90 04:00
=MAX(A2:A5) will return 150 and
=MIN(C2:C5) will return 50
How can I find the values in COL B in same row as 150 (for MAX) and in COL D in the same row as 50 (for MIN)?
If you can confirm that you have only one max(min) value (if not, formula returns first occurance), you can simply use VLOOKUP:
=VLOOKUP(Max(A2:A5),A2:B5,2,0)
for min formulaa would be the same:
=VLOOKUP(Min(C2:C5),C2:D5,2,0)
Alternatively you can use more flexible formula:
=INDEX(B2:B5,MATCH(Min(C2:C5),C2:C5,0))
above formula finds min in column C and returns corresponding value from col B

Resources