I have three columns; Customer Name, Active License, Account Connected -
Customer Name
Active License
Account Connected
Alex
Yes
Yes
Barry
Yes
No
Alex
No
No
Claire
No
No
Alex
No
No
Deborah
No
No
I am using this formula to count the number of unique customers that have at least 1 active license: =COUNTUNIQUEIFS(A2:A,B2:B,"Yes") and the same to count the number of customers with at least 1 account connected. =COUNTUNIQUEIFS(A2:A,C2:C,"Yes")
How can I combine the two formulas to count the number of unique customers who have at least one active license AND at least one account connected. And how can I do it in the negative; counting the number of unique customers who have at least one active license but *don't have any connected accounts.
Thanks a lot :)
Use "basic" is correct in his comment to your original post that the following will give you the unique count of "Yes/Yes":
=COUNTUNIQUEIFS(A2:A,B2:B,"Yes",C2:C,"Yes")
However, his second suggestion will not produce the "Yes... without any second Yes'es." This is because some users with a "Yes/Yes" may also have entries with "Yes/No"; but they should not be counted since they do have at least one "Yes/Yes".
Instead, you'd use the count of all "Yes/?" and subtract those with any "Yes/Yes":
=COUNTUNIQUEIFS(A2:A,B2:B,"Yes") - COUNTUNIQUEIFS(A2:A,B2:B,"Yes",C2:C,"Yes")
If you already have a cell containing the "Yes/Yes" count somewhere (say, D2), you can just sub that into the formula:
=COUNTUNIQUEIFS(A2:A,B2:B,"Yes") - D2
And if you have both the "Yes/?" count in a cell (say, C2) and the "Yes/Yes" count in a cell (say, D2), you can reduce to just the cell references:
=C2 - D2
This seems like it was more of a logic question than a Sheets question, per se. But there's my take on it.
Related
So I have a file of the form above. The hyperlinks you see in row 2 are suppliers. Under each supplier there is the cost for the EAN in that row (EAN is in column A). I am trying to return in column B the minimum price + the supplier that is offering that. How can I do this?
So far I have just done min(rowX) to get the minimum price (as you can see in column B), next I imagine I can use ampersand to concatenate this to the supplier in question but not sure how to use "offset" (or otherwise) to get the supplier? For example, in column B, the first entry should become:
"11.77 - FennixBrokers"
This is in reference to the fact that the minimum price offered by any supplier for this EAN is 11.77 and in this case that happens to be an offer from FennixBrokers.
try:
=BYROW(C3:Z,LAMBDA(z,IF(COUNTA(z)=0,,MIN(z)&" - "&FILTER(C2:Z2,z=MIN(z)))))
Not sure how to describe this one, so apologies for the vague title.
I'm trying to identify when a specific value in a column in Google Sheets appears more than once, but only if the value in a separate column is different. A visual will probably help here:
So in this scenario you can see that the 1111 ID is assigned to James twice and Nicole once. It's absolutely fine that 1111 is listed multiple times. But it's not good that it's assigned to more than one unique person. So my desire is for every row using the 1111 ID gets flagged with a formula (as seen in the 'Status' column) so that I can filter for it and handle the problem.
The example above uses names for the Owner, but that could be numbers instead.
Here is an example sheet:
https://docs.google.com/spreadsheets/d/1eBF3G6UAICgzUJdUA8onGyJiba0Wmu4DOK3U6-SQz7c/edit?usp=sharing
If Owner is in column A and ID is in column B then, for Excel, you could put this in C2 and copy it to the other cells in column C:
=IF(COUNTIFS(B:B,B2)=COUNTIFS(A:A,A2,B:B,B2),"Good","Mismatch Detected")
It compares the count of the ID against the count of the ID and the name. If the ID 1111 appears 3 times but James,1111 only appears 2 times there is a mismatch.
You probably want to change the A:A and B:B to be the range of your actual data.
You can try in GS:
=ArrayFormula(IF(LEN(A2:A),IF((COUNTIF(A2:A&B2:B,A2:A&B2:B)=COUNTIF(B2:B,B2:B)),"Good","Bad"),))
try:
=INDEX(IF(A2:A="",,IF(COUNTIFS(A2:A&B2:B, A2:A&B2:B)=1, "mismatch", "good")))
i'm confused with the following condition, simply i want to have arrayformula or maybe a custom-formula to increment number in a way bound by specific condition based on value in other column, put it simply :
if the group doesn't change and sub-group is different increment number by 1
else if the group doesn't change and sub-group is doesn't change (same) hold value by previous
else if the group change regardless sub-group value reset number back to 1
for ilustration
** notes Number is the result that i want, in example i fill it manually
Group
Sub-Group
Animal
Number
Land
poisonus
snake
1
land
friendly
dog
2
land
friendly
cat
2
land
scary
lion
3
aquatic
friendly
nemo fish
1
aquatic
predator
shark
2
UPDATE (dummy file link) :
https://docs.google.com/spreadsheets/d/1DAPf-DvWz50_DJ0IqAoSHbfEnfg_mN1lNXHcCjkj27M/edit#gid=0
try:
=INDEX(IF(A4:A="",,VLOOKUP(A4:A&B4:B, {UNIQUE(A4:A&B4:B), COUNTIFS(
REGEXEXTRACT(UNIQUE(A4:A&"×"&B4:B), "(.*)×"),
REGEXEXTRACT(UNIQUE(A4:A&"×"&B4:B), "(.*)×"),
SEQUENCE(COUNTA(UNIQUE(A4:A&"×"&B4:B))), "<="&
SEQUENCE(COUNTA(UNIQUE(A4:A&"×"&B4:B))))}, 2, 0)))
I have entered my solution in cell D1 of the sheet "Erik Help." As I said in the comments to your original post, this is a more complex solution than I can generally offer here on the free, volunteer-run forums. I did choose to develop and share the formula with you, but I will need to leave it to you (and any other future site visitors who may be interested) to study the formula for understanding how it works. Explaining the formula would take longer than writing it.
Here is the formula:
=ArrayFormula({"Number"; IF(A2:A="",,VLOOKUP(LOWER(A2:A&B2:B),QUERY({UNIQUE(FILTER({A2:B,A2:A&B2:B},A2:A<>"")),COUNTIFS(QUERY(UNIQUE(FILTER({A2:B,A2:A&B2:B},A2:A<>"")),"Select Col1"),QUERY(UNIQUE(FILTER({A2:B,A2:A&B2:B},A2:A<>"")),"Select Col1"),SEQUENCE(COUNTA(QUERY(UNIQUE(FILTER({A2:B,A2:A&B2:B},A2:A<>"")),"Select Col1"))),"<="&SEQUENCE(COUNTA(QUERY(UNIQUE(FILTER({A2:B,A2:A&B2:B},A2:A<>"")),"Select Col1"))))},"Select Col3, Col4"),2,FALSE))})
I am trying to count the unique values of a column, based on their status in another column, example:
Customers
License Active
Adam
Yes
Barry
No
Adam
No
Claire
No
In this situation, I want to know how many customers have at least 1 active license, and how many customers do not have at least one active license.
The formula I have tried is:
=COUNTUNIQUEIFS(A2:A,B2:B,"Yes")
This returns 1 in this situation which is correct, as there is 1 customer who has a Yes on column B.
My issue is when I try to do the reverse, count the "No" using this formula:
=COUNTUNIQUEIFS(A2:A,B2:B,"No") it returns 3 which is not the desired result as it is counting the second Adam as a unique value too because they have a "No" in column B.
The result I want here is 2, because Adam has a yes somewhere in column B so I don't want him counted again the next time his field is counted.
It seems to me that the easiest way to get the "No" count is like this:
=COUNTUNIQUE(A2:A)-COUNTUNIQUEIFS(A2:A,B2:B,"Yes")
It's even easier if you've already pulled the "Yes" count to a cell (say, C2), in which case the "No" count could be gained quite simply with this:
=COUNTUNIQUE(A2:A)-C2
I don't think you can do it in a single step - try filtering out those with at least one "Yes" like this:
=countunique(filter(A2:A,countifs(B2:B,"Yes",A2:A,A2:A)=0))
Explanation
When a countifs has a range instead of a single value in its criteria part countifs(B2:B,"Yes",A2:A,A2:A) , the countifs gets re-evaluated for each cell in the range. So you get an array with the results of
countifs(B2:B,"Yes",A2:A,A2)
countifs(B2:B,"Yes",A2:A,A3)
countifs(B2:B,"Yes",A2:A,A4)
countifs(B2:B,"Yes",A2:A,A5)
and so on all the way down the columns.
The first countifs above checks right through a2:a and b2:b to see if there are any cases where the name is Adam and the license condition is true and gets a count of 1 so that row is filtered out. The same thing happens in the next row containing Adam (row 4) - the countifs checks right through both columns excluding the headers and the count is still 1 so that row is filtered out as well leaving just Barry and Claire.
If you wanted to exclude all records containing "Test" in the Customer column, You could add a condition to the filter using the multiplication operator to 'AND' it with the existing condition:
=countunique(filter(A2:A,(countifs(B2:B,"Yes",A2:A,A2:A)=0)*(A2:A<>"Test")))
If you had several names to exclude, you would probably want to make a list of them and use a lookup to stop the formula getting too long and unwieldy, but it would be the same idea.
Thank you ahead of time for anyone who can help me with this, I think I am close, but it still isn't working.
I have a simple sheet activity reporting sheet that I am asking staff to complete over the upcoming year - It has 5 columns:
Column A: Date -In format (4/4/2013 13:30:00)
Column B: Title -In format (text string)
Column C: Attendance -In format (Numbers)V
Column D: Vol led - In format (text string)
Column E: Staff Led - In format (text string)
Using this data I am 90 % positive that I can aggregate on a different summary sheet that contains some static data like months (in the B column) to aggregate on. I am having trouble configuring the criteria in the filters though to cause the correct output to either sum or count .
Quantity of events ed by either staff or vol, if neither box is checked the event should not be counted) Right now I am trying this but it is not working
=SUM(FILTER('Hostel Activities'!A:A,MONTH('Hostel Activities'!A:A)=$B3, NOT(AND(ISBLANK('Hostel Activities'!D:D),ISBLANK('Hostel Activities'!E:E)))
Total number of attendance in a month for activities led by staff or volunteers Right now I am trying this but it is not working
=SUM(FILTER('Hostel Activities'!A:A,MONTH('Hostel Activities'!A:A)=$B3, NOT(AND(ISBLANK('Hostel Activities'!D:D),ISBLANK('Hostel Activities'!E:E)))
THIE WORKS! ## Heading ##Total number of volunteer led activities in a month for activities Right now I am using this and it IS working
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3,not(isblank('Hostel Activities'!E:E))))
Thank you for any assistance and/or guidance
Danny
The first problem I see with your first two formulas is that you're calling SUM on your FILTER result. But the FILTER is returning the column A, which are dates. So, your basically summing dates, which will surely not yield the result you're looking for. Why are you not using COUNT, as you did on your last formula?
Second, the first two formulas you pasted are identical, how do you expect them to return different results?
It seems that for the first two want to sum an OR condition. You can do this two ways (that I can think of now). The simpler to understand is just to sum two COUNT(FILTER(... formulas, one for each criteria, e.g.
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3,not(isblank('Hostel Activities'!D:D)))) + B6
Assuming that on B6 is the other COUNT formula (the 3rd one, that already works).
Another option would be to use an OR function as criteria for the FILTER. Like this:
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3, OR(NOT(ISBLANK('Hostel Activities'!E:E)), NOT(ISBLANK('Hostel Activities1!D:D))) ))
I believe I have figured out a method that works by making some adjustments in the formulas and the source data.
Basically
IN THE SOURCE REPORTING DATA:
I combined columns D and E into the same column and added data validation so the coordinator has to enter if the activity is led by staff,volunteer, or neither.
IN THE MONTHLY AGGREGATION REPORT:
To count the number of activities led by either staff or volunteers I used this :
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3,'Hostel Activities'!D:D="Staff"))+E3
*E3 is the count of volunteer led activities which is found using this formula:
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3,'Hostel Activities'!D:D="Volunteer"))
Adding up the number of participants in activities run by either staff or volunteers was a little more difficult, but I was able to do it by adding up 2 unique equations. I would prefer using an OR statement in the filter criteria, but I just couldn't get that to work. This is how I was able to make it happen:
=SUM(FILTER('Hostel Activities'!C:C,month('Hostel Activities'!A:A)=B3,'Hostel Activities'!D:D="Staff")) + SUM(FILTER('Hostel Activities'!C:C,month('Hostel Activities'!A:A)=B3,'Hostel Activities'!D:D="Volunteer"))
Thank you all for your assistance