What is the best way to use Index Match in this case? - excel

In the primary worksheet, I have a list of employees in column A, from columns D:ZZ I have basically a calendar in row 11. Where these intersect, I have assigned a task code to each employee to illustrate what they are employed to do that day. I want to dynamically color the coded cell based on the date in the row 11 and code from the column that it was entered. In my second sheet, I have a table of the codes along column A. From columns B:AM, in row 2 (under the header) I have another code that says what type of work it is, in office, on the road, etc. This is the code I am trying to look up with Index Match. In the row with the task code, under each header I have a scheduled date that that particular job will be either in or out or nothing.
I can Index the task column pretty easily, my problem is how would I take the row I get from that, then search only that row for the date that I applied the code to the employee to return the result from row 2 and the column that that date appears?
I have a pretty good understanding of Index/Match in looking up multiple items to return a result. I am having a problem creating a range from a result to find the data I want.
I have tried Indirect and Address as well as Offset, but I don't want this to be volatile as it is being used in conditional formatting over several thousand cells.
Task Code Schedule Worksheet
DAY 1 2 3 4 ...
CODE A S A F ...
96T003 03 May 04 May 05 May 06 May ...
96T004 05 May 06 May 07 Jun 10 Jun ...
96T005 05 May 19 Jul 22 Jul 23 Jul ...
Primary worksheet
SAT SUN MON TUE WED
DATE 01 02 03 04 05
JONES OFF OFF 96T003 96T003 96T004
DAVIS OFF OFF 96T003 96T003 96T005
This formula works, but is "volatile" and I am leary to use it in a conditional formatting function. Is there a way to make it not as volatile?
=INDEX(CMP_FLYCODE,1,MATCH(F11,INDIRECT("'CMP'!"&ADDRESS(MATCH(F19,CMP_ADP,0),1)&":"&ADDRESS(MATCH(F19,CMP_ADP,0),40)),0))
CMP_FLYCODE is a reference to just the A, S and F code row
Expecting to return a letter code A, S or F based on the date and code
Edit: Added the header to the code schedule that is a unique number for the day of the task 1, 2, 3...

I don't think it's too bad, you can just get the entire row from the 2d array B3:E5 in the task sheet using index with the match for the task code in the row parameter and 0 in the column parameter, then match the date in that and use index again to get the required letter code.
This is what my formula looks like:
=IF(C3="OFF","",INDEX(Tasks!$B$2:$E$2,MATCH(C$2,INDEX(Tasks!$B$3:$E$5,MATCH(C3,Tasks!$A$3:$A$5,0),0),0)))
This is my primary sheet:
This is my task sheet:
So to use this in conditional formatting, you would need three rules using custom formulas
=INDEX(Tasks!$B$2:$E$2,MATCH(C$2,INDEX(Tasks!$B$3:$E$5,MATCH(C3,Tasks!$A$3:$A$5,0),0),0))="A"
=INDEX(Tasks!$B$2:$E$2,MATCH(C$2,INDEX(Tasks!$B$3:$E$5,MATCH(C3,Tasks!$A$3:$A$5,0),0),0))="S"
=INDEX(Tasks!$B$2:$E$2,MATCH(C$2,INDEX(Tasks!$B$3:$E$5,MATCH(C3,Tasks!$A$3:$A$5,0),0),0))="F"
with appropriate fill colours.

Related

Excel formula to look up date that corresponds with 2nd 'non zero' value in column

In an excel model with two columns, column A = date by month, column B = cash projections (only two values in column B). Hoping to create a formula to search column b for the second value and return the corresponding month from column A.
In example below, looking for formula to return 'May 20' as answer
Column A
Column B
Jan 20
240,000
Feb 20
Mar 20
Apr 20
May 20
345,000
Jun 20
Tried using a min/max function, however, the second value is not consistently higher or lower than the first value. Assuming it can be done with some type of INDEX or LOOKUP function, however, I am unsure of how to select the second non-zero value

Excel Conditional formatting on two criteria in a separate table

This is a reporting presentation exercise...
I am looking for the magic to change the colour of the cell without changing the contents of the cell.
I have a type of crosstab table, which has the ROWS individual CustomerIDs, and the COLs as months.
PRESENTATION TABLE
CustomerID
Jan 22
Feb 22
Mar 22
0001
$100
$50
$10000
0002
$1000
$1000
$200
....
....
...
And in a separate table, I have some data which I want to use in a conditional formatting type of way.
LOOKUP TABLE
CustomerID
Period
Label
0001
Feb 22
Applied
0001
Mar 22
Pending
0006
Mar 22
Approved
0009
Dec 23
Pending
Let's say that if the CustomerID and Period in the data table has the label "Applied" then I want that cell in the top table, where CustomerID and Period intersect, to be coloured RED. If it's "Passed", I want it to be coloured green, and so on.
The periods are dates data types. The tables are excel tables.
The dollar value in the cell has nothing to do with it.
I've seen some techniques where a combination of Named ranges and confditional formatting are used, but I'm stumped.
I can put the dollar values in the correct cell by putting a helper column into my source data (the second table) and then doing an xlookup on the combination of the row and col headers, against that helper column.
But then I run out of steam.
END RESULT
CustomerID
Jan 22
Feb 22
Mar 22
0001
RED
BLUE
0002
....
....
...
Conditional Formatting On Two Criteria In A Separate Table
This is what I have tried,
• Formula used in Conditional Formatting for Applied
=COUNTIFS($F$2:$F$5,$A2,$G$2:$G$5,B$1,$H$2:$H$5,"Applied")=1
Special credit to Scott Craner Sir for the above formula
• And for the Pending you may try using SUMPRODUCT() or COUNTIFS() Function as well, both way it works,
=SUMPRODUCT(($A2=$F$2:$F$5)*(B$1=$G$2:$G$5)*($H$2:$H$5="Pending"))=1

How to COUNT between a date range if nested within another formula?

I am trying to substitute '!!!!!!' for a formula to count the number of W in column P on sheet TRADE LOG between the dates of 01 Feb 2021 and 28 Feb 2021 in hardcoded format.
This is the current formula :
=IF(COUNTIFS('TRADE LOG'!P:P,"W",'TRADE LOG'!B:B,">="&DATE(2021,2,1),'TRADE LOG'!B:B,"<="&DATE(2021,2,28)),"!!!!!!","")
Could anyone suggest what needs to be added in order to achieve this?
To make this clearer, I want F16 in STATISTICS to count the number of W's in sheet TRADE LOG column P between the dates of 01 Feb 2021 and 28 Feb 2021. However, if there is none I would like F16 to return a blank.

How to find number of matching values with an ID?

I have a unique list of IDs of people on two separate sheets. One for initial 'registration data' which is the master data list. In column A is the ID, column B is their town of residence and column C is the date in which the person was added to the list.
I send out sheets to the different towns every month to receive some more data about the new people added to the list, and every month (the same month) they should send it back to me. This received data goes onto a second sheet, with again: column A for person, B for town, and C for month data received.
I need to check how accurate the towns are in getting the data back to me on time. So I need to count the number of forms on the second sheet where the month is the same as the initial month on sheet number one, and the towns match too.
I have tried COUNTIFS with VLOOKUPs but am having no luck. I want to avoid having to make an interim data table as much as possible because I need the process to be slick and automatic.
Could this be done with a SUMPRODUCT?
For example:
Sheet 1 (initial) Sheet 2 (received)
123, TownA, Feb 123, TownA, Feb
124, TownB, Feb 124, TownB, Mar
127, TownB, Mar 127, TownB, Mar
130, TownC, Mar 130, TownC, Mar
220, TownC, Apr (we didn't receive back 220)
OUTPUT SHEET
Feb Mar Apr
TownA 1 0 0
TownB 0 1 0
TownC 0 1 0
As you can see, of the five forms we only received three in the month we were supposed to. I want it in the view above, and don't really want to have to make a new sheet with the IDs to match the months up.
In Sheet3 with Feb in C1, Mar in D1 and Apr in E1 and 123 etc in A2 etc, in B2:
=VLOOKUP(A2,Sheet1!A:B,2,0)
in C2:
=(INDEX(Sheet1!$C:$C,MATCH($A2,Sheet1!$A:$A))=C$1)*(INDEX(Sheet2!$C:$C,MATCH($A2,Sheet2!$A:$A))=C$1)
C2 copied across to E2 and B2:E2 copied down to suit.
Then select A:E and DATA > Subtotal At each change in: (ColumnB), Use function: Sum, Add subtotal to: check Feb, Mar, Apr, Summary below data and OK.
Copy A:E, Paste Special, Values over the top and apply filter. Filter ColumnB, Text Filters, Custom Filter..., contains Tot, OK.
In the first populated cell in ColumnB enter =Bn (where n is the row number immediately above that cell, though not visible) and copy down to suit.
Hide or delete the totals row to suit.

add values for a range between reference date minus 6 days in excel

i would like to add the corresponding values of dates with reference to a particular date and -6 days in excel.
For example: reference date is 10th feb 15. I would like to add values under flight time column for dates ranging between 10th feb 15 and previous 6 days.
similarly add values for a reference date and previous 30 days values and 1 year values.
What i wanted was, sum all the flight timings of a particular date in column A. I used the sumifs formula to achieve this.
The formula is =SUMIFS($I$8:$I$1122,$A$8:$A$1122,"<="&C8,$A$8:$A$1122,">="&C8-6)
What it does: Here the reference cell is C8 which is 6th Feb 14
step 1- date range for the calculation is 6th feb 14 minus 6 days
step 2- add the values of column I which correspond to all the dates that fall within 6th feb 14 to 31st jan 14
step 3- indicate the sum in column K
Unfortunately i cannot include any pictures or files to show what i have mentioned due to site limitations.

Resources