Count unique items on a list that meet multiple criteria - excel

This sounds simple, but I'm getting a real headache trying to figure it out:
I have two tables in excel in the same workbook but on different sheets. I want to count unique items in column B on the first table that meet a criteria (based on the data that's in column A of that table) and appear on the second table (on a different worksheet).
Because the data I'm working with is confidential, I've made up the two tables below (I've just clipped .jpgs). They are similarly formatted, but in reality I have much more data.
I need a formula that counts the number of unique people in Column B of Table 1 who also appear in Column B of Table 2 and whose date (in Column A of Table 1) is on or before 4/2/2016.
In this example it should come out with the answer three (for Bob, Jim, and Sue).
Table 1
Table 2
Any help you can provide would be hugely appreciated!!

If you put this =IF(AND(COUNTIF('Second Table'!$B:$B,'First Table'!$B2)>0,$A2<DATE(2016,4,2),SUMIF(B1:$B1,B2,$C$1:$C1)=0),1,"") in C2, then auto-fill it down would do it and you could sum it then at the bottom..

Related

Excel count Unique ID's between two dates + a distinct count of another column for each ID

I am struggling with an Excel formula. I am trying to count the number of Unique ID's between two dates (I have that formula working), but I also want to count the SignUpRoles for each unique ID that qualified between the two dates. I am using O365.
Here is how I am capturing the UserId counts in K10:14
=SUM(IF(FREQUENCY(IF(Weartime13[RecordDate]>=K5,IF(Weartime13[RecordDate]<=J5,MATCH(Weartime13[UserId],Weartime13[UserId],0))),ROW(Weartime13[UserId])-ROW(A5)+1),1))
Here is the worksheet I am working with: RDS_Report
Screenshot:
RDS Report Screenshot
So what I mean by adding another 'if' is that in L14 (for example) you would have
=SUM(IF(FREQUENCY(IF(Weartime13[RecordDate]>=O5,IF(Weartime13[RecordDate]<=J5,IF(Weartime13[SignUpRole]=L9,MATCH(Weartime13[UserId],Weartime13[UserId],0)))),ROW(Weartime13[UserId])-ROW(A5)+1),1))
and in the next column that would change to M9 and N9:
=SUM(IF(FREQUENCY(IF(Weartime13[RecordDate]>=O5,IF(Weartime13[RecordDate]<=J5,IF(Weartime13[SignUpRole]=M9,MATCH(Weartime13[UserId],Weartime13[UserId],0)))),ROW(Weartime13[UserId])-ROW(A5)+1),1))
=SUM(IF(FREQUENCY(IF(Weartime13[RecordDate]>=O5,IF(Weartime13[RecordDate]<=J5,IF(Weartime13[SignUpRole]=N9,MATCH(Weartime13[UserId],Weartime13[UserId],0)))),ROW(Weartime13[UserId])-ROW(A5)+1),1))
I've filled in the last row:
EDIT
As noted by #JosWoolley, a structured reference would have been preferable to row(A5). I would suggest:
=SUM(IF(FREQUENCY(IF(Weartime13[RecordDate]>=O5,IF(Weartime13[RecordDate]<=J5,IF(Weartime13[SignUpRole]=L9,MATCH(Weartime13[UserId],Weartime13[UserId],0)))),ROW(Weartime13[UserId])-ROW(Weartime13[#Headers])),1))
But what if you want to pull these formulas across so that L9 changes automatically to M9 and N9 but it still references the same table columns? I had to look this one up and the answer is:
=SUM(IF(FREQUENCY(IF(Weartime13[[RecordDate]:[RecordDate]]>=$O5,IF(Weartime13[[RecordDate]:[RecordDate]]<=$J5,IF(Weartime13[[SignUpRole]:[SignUpRole]]=L9,MATCH(Weartime13[[UserId]:[UserId]],Weartime13[[UserId]:[UserId]],0)))),ROW(Weartime13[[UserId]:[UserId]])-ROW(Weartime13[#Headers])),1))
Formula for the last row using count & filter would be
=COUNT(UNIQUE(FILTER(Weartime13[UserId],(Weartime13[RecordDate]<=J5)*(Weartime13[RecordDate]>=O5))))
for the total and
=COUNT(UNIQUE(FILTER(Weartime13[[UserId]:[UserId]],(Weartime13[[RecordDate]:[RecordDate]]<=$J5)*(Weartime13[[RecordDate]:[RecordDate]]>=$O5)*(Weartime13[[SignUpRole]:[SignUpRole]]=L9))))
pulled across for the SignUpRole breakdown, assuming UserId is numeric.
But what if you wanted a single formula that could be pulled both down and across for the whole range of dates and roles? This could be arranged as follows:
=COUNT(UNIQUE(FILTER(Weartime13[UserId],(Weartime13[RecordDate]<=J$5)*(Weartime13[RecordDate]>=INDEX($K$5:$O$5,ROW()-ROW($9:$9))))))
for the total and
=COUNT(UNIQUE(FILTER(Weartime13[[UserId]:[UserId]],(Weartime13[[RecordDate]:[RecordDate]]<=$J$5)*(Weartime13[[RecordDate]:[RecordDate]]>=INDEX($K$5:$O$5,ROW()-ROW($9:$9)))*(Weartime13[[SignUpRole]:[SignUpRole]]=L$9))))
for the role columns.
Is there a simpler way of doing this whole thing? Maybe with pivot tables or perhaps power query, but that would be a separate answer :-)

Return all matches in columns using one criterion (from drop down on another sheet)

I am having two tables, one table (table 1) below is main data, separated into many columns and blocks per 10 rows in one, as you can see A2:A11, A12:A21 and so on (many rows and columns) ... In Column A are unique numbers, but one number per block as a unique, and all other information in other columns can differ, sometimes will be more data sometimes not. The data is always same structured.
What I am looking is to have report / printable sheet where I will have all my columns on one sheet, but in a Column A2 for instance drop down list that will use all unique numbers from main data table and populate all matches on report page, same as it is on picture below. There are many columns that should work automatically when I choose something from "Number" drop down. The trick here is, there must be 10 rows per block also, I have organized it as it should be, but I can't figure out how to populate using functions. So, you can imagine clicking one drop down and getting those lists updated without scrolling endlessly through columns and rows on main data table...
Where I have a problem is that I am getting matches only for first rows but not whole rows (or all rows where matches are) ...
using this function:
=INDEX(Table1[Datum];SMALL(IF(Table1[Nummer]=Printable!$A$2;ROW(Table1[Nummer])-ROW(INDEX(Table1[Nummer];1;1))+1);1))
If someone can help me out, I would be happy!
Try below formula. After putting formula to cell drag down and across as needed. I have tested this formula in Excel2013 and with range (not as table). So, you have to adjust formula for table. I suggest you to first test the formula in single sheet like my screenshot and if it is successful then go for table in Report sheet.
=INDEX(INDEX(B:B,MATCH($G$2,$A:$A,0)):INDEX(B:B,MATCH($G$2,$A:$A,0)+9),ROW(1:1))

To lookup multiple conditions in different sheet and show all result in column by column- possible to do it with excel formula or vba is required?

need some help on my excel production report.
I want to Lookup for the daily unique ID, gram and pieces from Sheet 1 into Sheet 2.
The daily unique ID consists of up to 5 categories.
Each day, there could be up to a maximum of 3 unique ID produced with each one having different categories (some have 2 same categories with different grams and pieces. It need to be shown in a separate column in Sheet 2), grams and pieces.
I came out with an excel formula but it only works IF there is only one daily unique ID per day. If there is more than one unique ID, this formula fails as it only captures the first one.
Please see my formula below
I2:I100 is the gram in Sheet 1
E2:E100 is the "unique code-category" in Sheet 1
D11 is the unique code in Sheet 2
P11 is the type of categories
{=IFERROR(INDEX('A'!$I$2:$I$100,SMALL(IF(($D$11&"-"&$P$11)='A'!$E$2:$E$100,MATCH(ROW('A'!$E$2:$E$100),ROW('A'!$E$2:$E$100)),""),ROWS($A$1:$A1))),"")}
Is there a way I could capture everything?
Can I do it with excel formula or a VBA is required?
I have tried many different formulas but nothing came out right, please help :(
Please let me know if my explanation isn't clear. Thanks.
Sheet 1
Sheet 2 (Final Report)

How do I SUM a column based on the match of 2 other columns with different sizes in Excel

Hello fellow developers,
I'm currently working on an accounting worksheet, and I'm stuck in one formula (by the way, i don't want to use VBA).
I need the SUM of a database based on a column, in ONE CELL (this is very important because i will make this sum in a lot of other cells based on other criterias)
1 - I have one table column with 25k rows (it will increase every month).
2 - I have another table with 250 financial accounts,
3 - I need in one formula the sum of column 2 from table 1, that matches the column 1 from table 1 with the accounts from table 2,
I tried SUMPRODUCT( and SUM(IF(, but my problem was comparing two ranges with different sizes since one has 25k and another 250
Any Ideas?
Thanks ^^

Distributing rows of small table based on values of a bigger table (Excel)

I have two tables of different lengths in Excel. The first column of the biggest table contains all the values of first column of the smaller table (and more). I would like the rows of the small table to be distributed to match the big table (creating empty rows when the values are missing). I would like to use a formula for this if possible (VBA code alternatively). I cannot do this manually because the actual tables I am working with have thousands of rows. Here are pictures describing what I am trying to do:
Initial lists
Result
EDIT: I should add that the first columns of both lists in the examples are numbers, but in the real lists I am working with the values are composed of letters and numbers
Any help would be greatly appreciated!
Thanks
I moved the "small" table over to make room for the results. I put them in F and G.
Then in C1 I put this formula:
=IFERROR(VLOOKUP($A1,$I:$J,COLUMN(A:A),FALSE),"")
Copy it over on column and down the extent of the large table.

Resources