Combining COUNTIFS with a VLOOKUP - excel

I have looked through other posts on here and cannot find the solution I need.
I am currently using this formula:
=COUNTIFS(Tracking!$F$3:$XA$3,$F1,Tracking!$F4:$XA4,"~*")
This is counting all the * values that match to the reference "Attainment" (This is cell F1), but is relying on my 2 worksheets to have the people listed in exactly the same order. What I really want is the countif to calculate based on matching the person ID.
I have 2 sheets that use a unique ID for each person. I want to be able to match this ID and then run the countif, so in essence combine a VLOOKUP with the COUNTIFS. I did try adding another criteraia to the COUNTIFS but this doesn't seem to work. No IDs are repeated in either sheet. The unique ID defines each row and the row holds a very large amount of grade data for the person.
Sample Data

I think you could accomplish this using this formula in F3
=COUNTIF(INDIRECT("Tracking!"&MATCH(A3,Tracking!$A:$A,0)&":"&MATCH(A3,Tracking!$A:$A,0)),"*~*")
This is using the row number of the match to COUNTIFS any cells with a * in that row.

Related

Excel Sumifs using numbers stored as text in criteria

I am trying to use the SUMIFS() formula in excel to exclude certain rows from a table, but the criteria range includes numbers stored as text.
In the picture below I want to exclude the rows where entity id is "101000". The SUMIFS() formulas I have tried all provide the incorrect solution.
I found similar problems (here and here). This is where I came up with the SUMPRODUCT alternative.
I am trying to see if there is an alternative using SUMIFS. The syntax of SUMPRODUCT is confusing. But more importantly it doesn't work if I have entity id's that both translate to the same number value ('0100' and '00100').
If you are using Office 365 you can combined the FILTER and SUM functions.
First FILTER the amounts
=FILTER(C4:C9,B4:B9<>"01000")
Then SUM the filtered amounts
=SUM(FILTER(C4:C9,B4:B9<>"01000"))
You can sum the rows whose IDs do match, and then subtract it from the total sum:
=SUM($C$4:$C$6)-SUMIF($B$4:$B$6,"101000",$C$4:$C$6)

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 :-)

Excel - INDEX / MATCH with different tables and multiple criterias

I have two Excel Sheets
Sheet 1:
Sheet 2:
What I'm trying to accomplish is to get excel to retrieve the date in the top row for the column that contains a value. I think I have found a way to do this without taking the Unique ID in account but I need to be able to add the ID as a criteria into this formula because my formula would only work if all the IDs are in the same order and part of both tables.
This is what I currently got : =INDEX($H$4:$Z$4;MATCH(TRUE;INDEX(H6:Z6>0;0);0))
How can I take into consideration the IDs in a way that excel matches the IDs also?
=IFERROR(EOMONTH(AGGREGATE(14,6,1/(INDEX($H$5:$Z$16,MATCH($G22,$G$5:$G$16,0),)<>"")*($H$4:$Z$4),1),0),"")
Older versions of Excel need this entered with ctrl+shift+enter.
This searches your data for the row where the ID meets the criteria (in this example I used G22 for the ID to match).
Aggregate checks for a non-empty cell in that range and returns the value in the header. EOMONTH then returns the last day of that month.
If there's no values or matching ID's it returns as blank.

Excel: Count Unique Dates for set of multiple criteria

I have a large spreadsheet with many data columns and dates . Column B is the date column and there are multiple rows of duplicate dates with different data in the following columns. I'm trying to write a formula to give me a count of how many unique dates there were given different criteria. I did this formula entered as an array and it worked perfectly.
=COUNT(1/FREQUENCY(IF(('NA Trades'!D:D="TSX D3")*('NA Trades'!DX:DX>16),IF('NA Trades'!B:B<>"",'NA Trades'!B:B)),IF(('NA Trades'!D:D="TSX D3")*('NA Trades'!DX:DX>16),IF('NA Trades'!B:B<>"",'NA Trades'!B:B))))
I tried expanding on this and adding more criteria but it doesn't seem to be working and giving me a result of 0. This is the array formula I tried with the added criteria
'=COUNT(1/FREQUENCY(IF(('NA Trades'!D:D="TSX D3")*('NA Trades'!DX:DX>16)*('NA Trades'!DQ:DQ<-2.6),IF('NA Trades'!B:B<>"",'NA Trades'!B:B)),IF(('NA Trades'!D:D="TSX D3")*('NA Trades'!DX:DX>16)*('NA Trades'!DQ:DQ<-2.6),IF('NA Trades'!B:B<>"",'NA Trades'!B:B))))
Where did I go wrong with the second formula and how can I format this formula so I can continue to add more criteria?
Your formula seems to be working fine, are you sure you have the correct data in your newly added column? BTW, I would suggest that you use named ranges or a table - it's easier to read.

Sum the product of multiple vlookup or index/match results

I have 2 worksheets, one with multiple columns of data where rows are given years and the other columns are values under the headers of names, and the second sheet lists rates by year (column) and by name (row).
I am trying to take each value in a given column of sheet1 and multiply it by the relevant rate (found by matching the year of each row and the name of its column to the table in sheet2) and then sum the products by name, but can only use a single cell to do all this.
So far I've tried SUMPRODUCT and got to =SUMPRODUCT(O$24:O$514,INDEX(Rates!$A$2:$X$200,MATCH(O$23,Rates!$A$2:$A$67,0),MATCH($D$24:$D$514,Rates!$A$2:$X$2,0))) but this seems to fall down at the MATCH($D$24:$D:$514,Rates!$A$2:$X$2,0) part, even entering as an array.
I've currently resorted to a clumsy series of SUMIF(2016)*INDEX/MATCH(2016 rate)+SUMIF(2015)*INDEX/MATCH(2015 rate) etc, but would really like to have forward compatibility without relying on formulae being updated!
slightly simplified image of the workbook, thanks for any help!

Resources