How to find number of matching values with an ID? - excel

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.

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

Need to revise this formula that displays data based on another cell's contents

I can't get this formula working properly. Here is what I need to do (see included image below):
I need the data in rows 9-10 (sales) to be displayed/copied in rows 28-29 (collections) based on the number in cells C9 and C10 (payment terms). For example, if there are $1,900 in GM sales on Tuesday, Jan 5 (cell F9) and payment terms are 10 days (cell C9), then I need $1,900 displayed on Tuesday, Jan 19 (cell P28), in the collections section (rows 28-29), 10 business days from when the sales were made. Does this make sense? Here is the formula I am using now (starting in cell E28 and being dragged to the right):
=IF(COLUMN() - E9 < 1, 0, INDIRECT(ADDRESS(9, COLUMN() - $C$9)))
However, it is not working completely. It is moving the data labels to the left of the data table that are not supposed to be included in the data table. Only sales data starting in cell E9 are supposed to be moved. You can see this issue in row 28 (columns J-N) in the image below.
This formula also has to work with payment terms from 1 day - 10 days. So, the $5,000 in Ford sales on Monday, Jan 4 (cell F10), with payment terms of 3 days (cell C10), needs to be displayed on Friday, Jan 8 (cell I29).
Let me know if you need any additional details to solve this issue. Thanks!
Is this what you're looking for?
=IFERROR(INDEX($E$9:$X$13,MATCH($B28,$B$9:$B$13,0),MATCH(WORKDAY(E$5,-INDEX($C$9:$C$13,MATCH($B28,$B$9:$B$13,0))),$E$5:$X$5,0)),0)
The formula indexes the sales amounts and shows the amount in the row where the customer name mentioned at sales equals the customer at the result section with the column where the result date equals the date mentioned at sales minus the number of workdays mentioned behind the customer name at the sales section.

Split data in a column to multiple rows

I have an excel sheet where column A contains month and column B contains sales. 1 month can have multiple rows with different sales. I need to sum up the sales in every month. And then output in a new worksheet titled "Report" with each row for a new month.
I could have:
Month Sales
Jan 15
Jan 5
Feb 3
Mar 4
Mar 8
I need to produce this:
Month Sales
Jan 20
Feb 3
Mar 12
Try using a pivot a table. Select the data range, go to Insert tab then press Pivot Table and OK (it will put the Pivot table into a new sheet by default).
Put Month into Rows box and Sales into Values box.
Have in mind that data appears in Column A (Month) & Column B (Sales). Range A2:B6.
Steps:
Select D2
Go Data - Data Tools tab - Consollidate
Reference: $A$2:$B$6
Press Add and ensure that the reference appears in All references box
Use labels in: Left Column
Press OK
Results:

Excel function to Auto-Populate value in Column C based on the combination of values in column A and Column B

I have 3 columns with values filled in already in my metasheet. A combination of values in column A and column B makes the selection unique. I need to pull/return the value in column C for the values selected in columns A & B. for example: In sheet 1, I have the following data:
country Month weather
1 USA Jan winter
2 USA Feb fall
3 USA May summer
4 China Jan summer
5 China Feb spring
6 China May fall
7 India Jan fall
8 India Feb summer
9 India May Rain
Now, say for a random row 25, I have A25 as a dropdown list with value selected ="India" and B25 as a dropdown list with value selected="Feb", in which case I would want C25 to have a dropdown list with the value in it being "Summer".
I tried this formula:
=VLOOKUP(B25, OFFSET(B$1:C$9, MATCH(A25,A$1:A$9,0)-1, 0, 2, 2), 2, 0)
But this one gives me an error: "The list source must be a delimited list, or a reference to a single row or column".
I did refer to this solution. But I get the above mentioned error as the data validation for C25 is a list.
Any suggestions/ideas on this would be helpful!
Thank you!
If your sheet is set-up like this:
You can use:
=INDEX(C2:C10,INDEX(MATCH(1,(A2:A10=E2)*(B2:B10=F2),0),0))
You will need to make a second sheet with a matrix like following -
Here you will define all the weathers for country and month pair. I have used the default name i.e. Sheet2 and filled the values that were available from your data. You will lookup the values from this for filling on Sheet1. Sheet1 will be like this -
=VLOOKUP(B2,Sheet2!$A$1:$D$13, MATCH(A2, Sheet2!$A$1:$D$1, 0), FALSE)
Here B2 is the month value, A2 is the country value. Sheet2!$A$1:$D$13 is the range for VLOOKUP and Sheet2!$A$1:$D$1 is the range for MATCH. VLOOKUP will match the month, MATCH will match the country and get the column index.

Excel SUMPRODUCT with dynamic column range to sum

A B C D
1 Department Jan Feb Mar
2 Marketing 100 200 300
3 R&D 150 250 350
4 Marketing 300 400 500
I have a sample file like the above table.
The SUMPRODUCT formula below only sums the specific rows and column, which is row 2 to 20 and column B to C for summing
=SUMPRODUCT((A2:A20="Marketing")*(B2:C20))
Actual formula (from comments):
=SUMPRODUCT(INDEX(BW!$A$3:$AE$3,MATCH(C$35,BW!$1:$1,0)+MATCH("JAN 2016",BW!$F$2:$R$2,0)-1):INDEX(BW!$A$108:$AE$108,MATCH(C$35,BW!$1:$1,0)+MATCH("A‌​UG 2016",BW!$F$2:$R$2,0)-1)*(BW!$B$3:$B$108=$E$1))
My questions, is there a way to make SUMPRODUCT dynamic, in a sense, it knows the first row to take will be 2nd and ends at 20.
As for the dynamic column to sum, it'll depend on the criteria. i.e. if the criteria is Feb and Mar, it'll take column C2:D20...again, the row is dynamic as well.
If you turn your range into a table called Table1 then the following should work:
=SUMPRODUCT((Table1[Department]="Marketing")*(INDIRECT("Table1[[Jan]:["&VLOOKUP("*",Table1[#Headers],COLUMNS(Table1),FALSE)&"]]")))
To make the SUMPRODUCT dynamic we can use INDEX/MATCH to find the extents of the data.
Then all that is need is to put the months wanted listed in one cell, I used I7
=SUMPRODUCT((ISNUMBER(SEARCH($B$1:INDEX(1:1,MATCH("ZZZ",1:1)),I7)))*($A$2:INDEX(A:A,MATCH("ZZZ",A:A))="Marketing")*B2:INDEX(A:DD,MATCH("ZZZ",A:A),MATCH("ZZZ",1:1)))
The INDEX(A:A,MATCH("ZZZ",A:A)) will find the last cell with text in Column A, and use that to set the extent of the dataset.
For the Last column we use INDEX(1:1,MATCH("ZZZ",1:1))
If you are not going to work with a ListObject (aka Structured) table, then a dynamic named range would certainly help.
Go to Formulas, Defined Names, Name Manager and when the Name Manager dialog opens, click New.
Give your defined name range a unique name; I've chosen Departments.
Leave the Scope as workbook and use the following formula for the Refers to:  =BW!$A$1:INDEX(BW!$A:$M, MATCH("zzz",BW!$A:$A ), MATCH(1E+99,BW!$1:$1 )) Columns A:M will cover a Department column and Jan through Dec. Note that Jan 2016-Dec 2016 are real dates (e.g. 1/1/2016 to 12/1/2016) formatted as mmm yyyy.
You should end up with the following dynamic named range:
Now you can 'shape' the sections of the defined range using INDEX/MATCH function pairs.
=SUMPRODUCT((INDEX(Departments, 0, 1)=Q3)*
(INDEX(Departments, 0, MATCH(R3, INDEX(Departments, 1, 0), 0)):
INDEX(Departments, 0, MATCH(S3, INDEX(Departments, 1, 0), 0))))

Resources