Finding a list of strings in a column - excel

I'm creating a personnel tracker, I'd like to "double check" that I have the people I need on a given day. With people as rows, and dates as the columns, I want to check the column for a particular day to see if I have coverage at a glance.
=IF(SUMPRODUCT(COUNTIFS(BR4:BR46,{"Mc";"Ec";"M";"F";"Fe";"W";"Fe";"Ca";"Ce"}))>=7,"T","F")
This seems to work, but after some experimentation it is counting other strings in the column (so W or F might match on WF) which isn't what I want.

COUNTIFS works differently when you use an array as the criteria. It outputs an array the size of criteria showing have many matches were made for each item in criteria. Instead of using SUMPRODUCT, you need to count the number of values above 0. I've solved it by forcing every value of 0 in the array to be an error, and counting all non-errors.
=IF(COUNT(COUNTIFS(BR4:BR46,{"Mc";"Ec";"M";"F";"Fe";"W";"Fe";"Ca";"Ce"})^0)>=7,"T","F")

Related

How to count similar groups of elements in Excel using multiple criteria?

I am trying to count groupings of elements in a list, in Excel, with groupings defined by 2 conditions: same Element and same Group code, as shown in the image below. The column C formula seems to throw errors as shown in orange highlighting in cells C9-C11. The formula for column C is displayed starting in column D. My expected grouping count is shown in column L with explanation starting in column M. Cells L9-L12 show what I expect the element count to be for Element X/Group 0.
Is there a correct formula for counting multiple-criteria groupings in Excel 365? I have tried various iterations of countifs() and sumproduct (See column D of the screencap) with no luck yet.
Post possible solution:
Now showing a scenario where the solution doesn't hold up (holds up in all other 16 scenarios I ran but not this one ???), see the orange cells with strange output versus expected output in yellow:
OK well in the first iteration of your question what seemed like a long time ago we all assumed that you wanted to count the total number of unique groups you have got so far. Now it's looking a bit different - the example implies that if both the element and group are repeated later on you want to revert back to the count of that element and group only and not the total count. I think what you want is a match like this:
=MATCH(A4&B4,SORT(UNIQUE(FILTER(A$4:A4&B$4:B4,A$4:A4<>""))),0)-
MATCH(A4&"*",SORT(UNIQUE(FILTER(A$4:A4&B$4:B4,A$4:A4<>""))),0)+1
Could be simplified using Let but it's late here and it's tentative anyway.
However the sorting assumes that the group keeps on increasing within each element and that wasn't the case in the first iteration of your question. You could try Sortby just sorting on the Element but that will have to wait till tomorrow.
EDIT
Here is my revised formula - plz try it.
=LET(range,A4:B$4,
unique,UNIQUE(range),
uniqueElement,INDEX(unique,0,1),
sortby,SORTBY(unique,uniqueElement,1),
sortElement,INDEX(sortby,0,1),
sortGroup,INDEX(sortby,0,2),
MATCH(1,(sortElement=A4)*(sortGroup=B4),0)
-MATCH(A4,sortElement,0)+1)
You could also use Take instead of Index. I've removed the filter for clarity because there aren't any blanks in the test data.

How to return the sum of an array if an object or objects exist across multiple columns

Here is my problem:
I need to search using or logic in a 2d array for any row that contains any given substring(s), and sum that row's sum column as a result.
I have a column, Hours, that I would like to sum if the column Name OR the column Description contain any number of criteria. So far my (ugly) solution is (pardon the formatting):
SUM(SUMIFS(B16:B100,C16:C100,{"(asterisk)Crit1(asterisk)","(asterisk)Crit2(asterisk)"}),SUMIFS(B16:B100,D16:D100,{"(asterisk)Crit1(asterisk)","(asterisk)Crit2(asterisk)"}))
This by itself is not bad, and with only 2 columns isn't horrible. But, some of you may have seen that this can cause double-counts if the criteria is in both columns, which I do not want.
So my question: Can I do this in such a way where I can search for criteria in multiple columns, and if they exist in any column, then sum the sum range, only once?
Try (untested since you show no data):
=SUM(B16:B100*((ISNUMBER(SEARCH({"Crit1","Crit2"},C16:C100))+ISNUMBER(SEARCH({"crit3","Crit4"},D16:D100)))>0))
Adding comparisons is like doing an OR; by comparing the sum of the comparisons to zero, we determine if any single one is present.
The formula may need modification if you have criteria which can be miscounted.
For example:
Note that Crit1 will return a match for Crit1, Crit101, etc. Depending on your actual data, a formula modification might be possible; or a UDF might be more practical.

I am having trouble with an excel formula

I am trying to come up with a formula in excel that allows me to have two separate criteria from two separate lists and then sum the total amount of values that meet those criteria. I can get the set of criteria to work, so
=COUNTIFS(Data!A:A,[#[Sub ID]] section allows me to see the amount of times a specific supID appears in column A. However, the second part where I am trying to see after that how many times any value from a particular list of values appears in a separate list, does not work.
Is there any way to make a formula count one list of values against another list of values without having to name each additional value in the formula.
I could do this if I wrote,
=SUM(COUNTIFS(Data!A:A,[#[Sub ID]],Data!B:B,{"=apples","=pears","=bananas"[....]}))
But I don't want to have to write out each additional value, the list is too long. I just want to have the list in a column so I can reference it in the equation but it wont let me.
=SUM(COUNTIFS(Data!A:A,[#[Sub ID]],Data!B:B,Mapping2!B:B))
You are creating an iterative formula, You want to limit the last criterion to just the data set:
Mapping2!B2:B15
Then use SUMPRODUCT which will force the iteration:
=SUMPRODUCT(COUNTIFS(Data!A:A,[#[Sub ID]],Data!B:B,Mapping2!B2:B15))

Add final two values of two running totals in Apple Numbers

I have two descending running totals, and I want to sum the last item in each running total.
I would like the total to be in a single cell, and the total in this instance to be £2500 + £4492.55. As the running total continues, I expect the total in this cell to update.
(Apple Numbers is similar to Excel, which is why I have used the Excel tag here).
This approach works only if the calculation is not below the column of values, but above it:
=INDEX(C:C,MATCH(99^99,C:C,1))+INDEX(C:C,MATCH(99^99,C:C,1)-1)
Edit
Microsoft Support pages for Index and Match. With the extraordinarily large number and the 1 as the last argument, Match will return the position of the last populated numeric cell. Index will then return the value of that cell. Repeat, but return the second last row, by subtracting a 1 from the Match result. Add the two results.
Edit two
Since you did not want to do what you first said you want to do, here is a formula for what you currently say you want to do. Assume the first list of numbers is in column C and the second list of numbers is in column G:
=INDEX(C:C,MATCH(99^99,C:C,1))+INDEX(C:C,MATCH(99^99,G:G,1))
Edit three
You've clarified in the comments that you're using Apple Numbers, not Microsoft Excel. Unfortunately the above formulae may not work in that system, and help for that probably is out of the scope for Stack Overflow.
I was overcomplicating things.
MIN(C:C) + MIN(G:G) yielded the result I was looking for.

Excel Mac: If these two arguments are true then count/sum the number of unique ID#s

This is what I am trying to figure out:
IF date in cell matches dates in range
and
If name in cell matches names in range
then
count/sum the number of unique ID#s
This is the formula I have:
=IF(Data!A:A=E10,(IF(Data!D:D=D11,(IF(Data!D:D=D11,SUM(IF(FREQUENCY(Data!C:C,Data!C:C)>0,1)),"ERROR3")),"ERROR2")),"ERROR1")
It does not output the correct info. It either counts all the unique IDs or it Errors out when it should have a result.
I hope I am on the right track, thank you for any help.
Sample dataset:
Try it as,
=SUMPRODUCT(SIGN((B$2:B$10>=E2)*(B$2:B$10<=F2))/
(COUNTIFS(B$2:B$10, ">="&E2, B$2:B$10, "<="&F2, A$2:A$10, A$2:A$10)+(B$2:B$10<E2)+(B$2:B$10>F2)))
First let me say that the question was pretty confusing before you posted an image of the data, as it appears that the term "dates in range" was completely misleading. In fact you are trying to match exact dates, not "ranges of date".
FREQUENCY is useful to detect the first appearance of an item in a column, but unfortunately, this "artificial trick" is not flexible enough to be mixed easily with other criteria, and most importantly FREQUENCY is not array friendly.
There's another method to achieve you goal, which is:
=SUMPRODUCT(((Data!$A$1:$A$24=E$10)*Data!$C$1:$C$24=$D11))/
COUNTIFS(Data!$A$1:$A$24,Data!$A$1:$A$24,Data!$B$1:$B$24,Data!$B$1:$B$24,Data!$C$1:$C$24,Data!$C$1:$C$24))
You can enter this formula in E11 in your sample image and copy/paste in the whole matrix.
The denominator of the formula (the second line) generates an array that counts for each row the number of duplicates.
The numerator sets the criteria. Since each successful row will repeat as many times in the numerator and in the denominator, each matching row will be counted for a total of one.
As a result, we obtain the number of "unique rows" that match the criteria.
The formula should not use complete columns such as A:A etc, make the effort to limit it to a reasonable number of rows, say A1:A999 or so. Complex formulas involving arrays must avoid as much as possible entire columns.

Resources