I have three functions that will return the answer that I'm looking for but I don't want to have these functions separate because the sheet would get too cluttered. That said, I'm having difficulties nesting these formulas so that it returns only the final output. The formulas are listed below:
=UNIQUE(FILTER('Sheet'!$D:$D, 'Sheet'!$B:$B >= B$2,'Sheet'!$B:$B<C$2,regexmatch('Sheet'!$L:$L,"Trial")))
This function returns all unique ID's that meet the conditions stated.
=COUNTIFS('Sheet'!$B:$B,">="&C$2,'Sheet'!$B:$B,"<"&D$2,'Sheet'!$G:$G,">0",'Sheet'!$D:$D,B27)>0
This function returns T/F if the identified unique ID from first function exists next month. Returns 'True' if ID exists, 'False" if it does not. Cell B27 refers to the first cell row from the first function.
=COUNTIF(C27:C45,TRUE)
This function counts all True for each month. Range (C27:C45) references the output from the second function
I tried
=COUNTIF(countifs('Sheet'!$B:$B,">="&C$2,'Sheet'!$B:$B,"<"&D$2,'Sheet'!$G:$G,">0",'Sheet'!$D:$D,UNIQUE(FILTER('Sheet'!$D:$D, 'Sheet'!$B:$B >= B$2,'Sheet'!$B:$B<C$2,regexmatch('Sheet'!$L:$L,"Trial"))))>0,TRUE)
but this function returns the incorrect answer.
Any ideas? Here's the sheet: https://docs.google.com/spreadsheets/d/1l2dXCEE0enTRBzBZEwjN1Fj9-ovPjsi75WvTdgK7_Zg/edit?usp=sharing
use:
=COUNTUNIQUE(IFNA(FILTER(sheet!$D:$D, sheet!$B:$B >= B$2, sheet!$B:$B < C$2,
REGEXMATCH(sheet!$L:$L, "Trial"), sheet!$G:$G > 0)))
SOLVED: Had to use =arrayformula nested over the three functions.
Column B shows the number of new subscribers.
Column C:V shows how many of the specified subscribers from ColB is retained over period of time.
Related
What I'm trying to do is find the name of the person who is ranked number 1 in the table shown below. I have tried =LOOKUP and =VLOOKUP but I get an error saying that a result can't be found, even though it's obviously there. I assume that I'm either using the wrong function or just not using it right.
I tried =VLOOKUP(1;D2:H19;1) and =LOOKUP(1;D2:H19;1) but neither seems to work.
Answer
The following formula should produce the behaviour you desire:
=INDEX(D2:D,MATCH(1,H2:H,0))
Explanation
=VLOOKUP can only be used to find values to the right of a search key. To find values to the left of a search key, use a combination of =INDEX and =MATCH.
The =MATCH function searches a specified range for a specified value and returns the relative position of the value in that range. In this case, the value to search for is 1, the range to search through is H2:H, and the 0 at the end specifies that the range is not sorted in any way.
The =INDEX function returns the contents of a cell within a range having a specified row and column offset. In this case, the range is D2:D, and the row is whichever row is returned by =MATCH. =INDEX could take a third argument if it was desired to specify a row offset as well, but that is not necessary here.
Functions used:
=INDEX
=MATCH
You sort your ascending order based on rank then return your desired data using INDEX() function. Try-
=INDEX(SORT(D2:H500,5,1),1,1)
=vlookup(1,{H2:H19, D2:D19},2)
Since vlookup only searches the 1st column of the input range, to use it, you need to flip the columns by composing a local array: {H2:H19, D2:D19}.
{} means concatenation. , in it means horizontal concatenation. With that, the rank column is now the 1st column in the input of vlookup and now vlookup works.
With our local array, the 2nd column are the names and therefore index should be 2.
Also note the use of comma to separate function inputs.
your VLOOKUP formula should look like:
=VLOOKUP(1, {H2:H19, D2:D19}, 2, 0)
also try just:
=FILTER(D:D; H:H=1)
or:
=SORTN(D:D; 1; 1; H:H; 1)
You can use query (usefull in case of ex aequo)
=query(D2:H,"select D where H=1",0)
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.
Ok, this is the updated linkI have multiple criteria to look through in my arrayformula(index(match())). The first two are simple as they reference the row the formula is calculating on. The last conditional I have is to find the highest occurrence in a given range, but ONLY if the other conditions are met...something like a filtered maxifs..any ideas?
Here is my code in column P =iferror(ArrayFormula(index($F:$F,match(1,("Fee Taken"=$C:$C)*(H12=$H:$H)(maxifs($M:$M,$H:$H,H2,$C:$C,"Fee Taken"),0))),""))
The result that I would like is to return from column F if the name matches that rows name, the transaction type is "Fee Taken" from column C, and THEN if those conditions are true I want it to find the max value from column M based on those two criterias and return the column F value for that max value row..
Ive attached some pictues to show my data.
The last part of the Match function where I have the Maxifs equaling to eachother is where I am confused; my thoughts were to see if the maxifs for the item in Column "M" can be used as a criteria..but I do not think so....I only want the highest occurence F:F if both conditions are met and it is the highest value for both those criteria in column M..
Please let me know if you need anymore info..Thanks![
Working formula will be:
=ArrayFormula(index($F:$F,match(1,--(M:M=(maxifs($M:$M,$H:$H,H2,$C:$C,"Fee Taken"))),0)))
i've the following formula the problem i've is, this isn't working as it should be.
=SUMIFS(E9:14,$I$16:$I,FALSE(),$H$16:$H,G8)
E9:E14 is the part which should be summed up when the checkbox in I16:I = FALSE and if the name matches in H16:H from G8. My problem is I am getting this error
The array arguments of "SUMIFS" vary in size
My question would be, how do I get this exact formula to work? Exactly these areas have to be covered and cannot be changed, otherwise everything else is broken.
EDIT: Added example spreadsheet
https://docs.google.com/spreadsheets/d/1DdTSZAfGTpoeun3k2qqkDMG1jnaUaSz6wgSf2heIIDI/edit?usp=sharing
You need to adjust your ranges. Here's how =SUMIFS() works and then you'll see why you need to adjust the function.
=SUMIFS() looks for ranges and then applies the logic. So when you are telling the function to summarise E9:E14 it interprets it as:
SUM(E9,E10,E11,E12,E13,E14)
provided the following conditions. The conditions will tell the function whether to include each of the components (i.e. E9,...,E14).
Whether a condition is met or not is decided using a simple boolean (true/false) array. This could for example be I9:I14=FALSE which is interpreted as the array
{IF(I9=FALSE),IF(I10=FALSE),...,IF(I14=FALSE)}
resulting in an array similar to this:
{TRUE,TRUE,FALSE,FALSE,FALSE,TRUE}
(assuming the conditions I9, I10 and I14 are met but not the other three. The same is done for the second condition (the values in column H being equal to the value in G8, resulting in another array similar to this:
{TRUE,FALSE,FALSE,TRUE,FALSE,TRUE}
(assuming that only the values in H9, H12 and H14 are equal to G8.
When the function compares the two condition arrays and returns an aggregate array similar to this:
{TRUE,FALSE,FALSE,FALSE,FALSE,TRUE}
because only for the first and the last value the conditions are met. Therefore the =SUM function becomes like this:
SUM(E9,FALSE,FALSE,FALSE,FALSE,E14)
where FALSE = 0 so it returns
=SUM(E9,E14)
Here's where you get into trouble
You try to pass the function conditional arrays that are of a different size to the sum array (E9:E14), in effect asking it to compare apples and the age of your neighbour. What you need to do is to create the calculation you have in column E in a new column in rows 24 down and use that as the sum range in =SUMIFS().
So basically i want to check if certain range of field is not blank or has a certain value
so
=ArrayFormula(COUNTIF(NOT(ISBLANK(H24:I28)), true))
will count if they are blank
How can i edit it to also search for a certain value so far i've tried :
=ArrayFormula(COUNTIF(NOT(ISBLANK(H24:I28)) OR(IFERROR(SEARCH("someValue",H24:I28,1)>0,FALSE)), true))
Here is a link to a sheet as an example:
https://docs.google.com/spreadsheets/d/1sc8xmLf8_EYFoQb3kNQRdxdd-9PemrJ4lDhTfIqCJNg/edit?usp=sharing
Update following OP's details:
Well i want to count every value except anything that starts with the word Empty basically
=COUNTIF(H24:I29,"<>") -
COUNTIF(ArrayFormula(REGEXMATCH(H24:I29,"Empty")),TRUE)
Functions used:
REGEXMATCH
ArrayFormula
COUNTIF
Initial answer
To find whether theValue exists or not, you can use the following formula:
=IF(COUNTIF(H24:I28,"<>")>0,IF(COUNTIF(H24:I28,"someValue")>0,"someValue","no value"),"empty")
To count how many times theValue exists, please use:
=IF(COUNTIF(H24:I28,"<>")>0,IF(COUNTIF(H24:I28,"someValue")>0,COUNTIF(H24:I28,"someValue"),"no value"),"empty")
(Of course you can adjust the "messages" to your liking)
Functions used:
COUNTIF
IF
You could use the OR() operator:
Example:
=ArrayFormula(OR(COUNTIF(NOT(ISBLANK(H24:I28)),true),IFERROR(SEARCH("someValue",H24:I28,1)>0,FALSE)))
References:
- OR() function