I'm trying to separate specific rows of data into a new sheet, based on the text string in Column H / 8;
=query({attendees_list!A2:N2},"select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13,Col14 where Col8='Show1 - Adult (Earlybird Pricing)'",1)
The query is working, in that it returns columns 1-14 from the 'attendees_list' sheet, but it doesn't seem to be applying the "where" condition, as its returning all rows regardless of the Column H value, rather than returning the specified value; 'Show1 - Adult (Earlybird Pricing)')
Here is a document with the example of the issue
https://docs.google.com/spreadsheets/d/1LEISiYnFeOloA5FDmzA3B5fhXVY_YJiivxedR5qurpU/edit?usp=sharing
I've tried different string quote types (ie; ''&"") but I can't figure out the issue.
Any idea where I'm going wrong here?
the issue is in the range A2:N2 <- that's one row and then 3rd query argument set to 1 will treat that single row as a header row and always output it whatever you setup in 2nd query argument
try:
=QUERY({attendees_list!A2:N},
"select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13,Col14
where Col8 = 'Show1 - Adult (Earlybird Pricing)'", )
Related
I am trying to get the last non-zero, non-blank value of a row within a column (Column F in my example image) wherein that row ALSO matches a Campaign name (Column D).
Most search results yield an Excel-specific variation of =LOOKUP(1,1/(L:L>0),L:L), but this doesn't work in Google Sheets.
I am trying to solve for Cell F23 = 2374.
I found and modified a formula which returns the last non-zero, non-blank value within a column reliably, but I don't know where to mix the additional filter (basically, D$2:D22 = D23) into the INDEX function.
Here is what I'm working with:
=if(
{{separate_formula_that_fetches_value_from_other_sheet}})=0,
INDEX((FILTER(D$2:F22,NOT(ISBLANK(D$2:F22)))), (ROWS(FILTER(D$2:F22,NOT(ISBLANK(D$2:F22))))),3)
)
Here is the example table:
Thank you for any help!
If you are trying to find inside RANGE B2:F22 which...
value in Column F is not empty and greater than 0, and
value in Column D matches D23,
try this, didn't test it, but it should work I think:
=LAMBDA(FILTER,
INDEX(FILTER,COUNTA(FILTER))
)(FILTER($F$2:$F$22,$F$2:$F$22>0,$D$2:$D$22=$D23))
Any help in figuring this out would be appreciated. I would like a forumla to calculate the number of times a code number appears more than once AND where type is A.
A sample set of data looks like the following:
In this case the forumla should return 1 as there is one case of a repeated code number (1) where type is (A) - first row and last row in this case.
Would the forumla be any different if I also had a third column and wanted that to be a certain value as well? Again with the test data below I would want this to return 1 in the case that I wanted to measure the number of times any code number appeared more than once where type=A and subtype=C:
.
Ihave started with the following which identifies the number of unique combinations in columns A and B, but I can't seem to add any way to only return where a particular combination appears more than once:
=COUNTUNIQUE(IFERROR(FILTER(A2:A,B2:B="A"),""))
I have tried the following but it doesn't return correctly:
=COUNTUNIQUE(IFERROR(FILTER(A2:A,B2:B="A",COUNTIF(A2:A,A2:A)>1)))
Been trying to figure this one out for a while with no success.
Thank you
You can try this (TABLE = the range corresponding to your dataset, including the header row):
=query(query(transpose(query(transpose(TABLE),,9^9)),"select Col1,count(Col1) where Col1 contains 'A' group by Col1",1),"select Col2-1 where Col2>1 label Col2-1 ''")
What we are doing is to concatenate the Code number & type columns into one using the TRANSPOSE/QUERY/TRANSPOSE...9^9 hack, querying it again to make a temporary table of each group against its count for those groups which meet the criteria, then finally subtracting one from each group count and only returning an answer if there were groups with count>1 to begin with. You will get multiple results if multiple groups satisfy the count>1 criteria.
To add the subtype column to the formula as per the second question, change TABLE to suit, then change the inner QUERY to:
"select Col1,count(Col1) where Col1 contains 'A' and Col1 contains 'c' group by Col1"
Note that the if your 'real' type & subtype categories share characters then the where/contains approach in the QUERY will fail and a different approach will be needed.
Assume that you place you data at A1:B10, what this function do is:
FILTER B1:B10 by type, which is "A" in this example, and return an array which is filtered A1:B10.
Use INDEX to extract only the 1st column, which is the code column of the filtered array, and name it 'DATA' with LAMBDA function.
Use BYROW to iterate 'DATA', and check each code with COUNTIF, if it counts more than one of this code in the filter result, return that code, else return "".
Use UNIQUE to get rid of duplicate results. (since we are looking for code which have more than 1 repeats, so the return array will sure have duplicates.)
Use query to get rid of the extry empty rows.
=QUERY(UNIQUE(
LAMBDA(DATA,
BYROW(DATA,LAMBDA(ROW,
IF(COUNTIF(DATA,ROW)>1,ROW,"")
))
)(INDEX(FILTER(A1:B10,B1:B10="A"),,1))
),"WHERE Col1 IS NOT NULL")
Just noticed that the INDEX function is not necessary, FLITER can directly returns A1:A10 according the compare results of B1:B10.
=QUERY(UNIQUE(
LAMBDA(DATA,
BYROW(DATA,LAMBDA(ROW,
IF(COUNTIF(DATA,ROW)>1,ROW,"")
))
)(FILTER(A1:A10,B1:B10="A"))
),"WHERE Col1 IS NOT NULL")
I'm using an index(match()) function to return a value based on the name of a column header. However, I've recently learned that a column header can appear 4 times in my data. However, there would only ever be one populated, the others would always be empty.
Whilst I could do a nested if =(isblank(...)# do stuff) I wondered if there was a more sophisticated way to tell GSheets to return the first non null / empty value, kind of like the SQL coalesque() function.
Is there?
Current formula looks like this:
=index('Form Responses 1'!$A$2:$DY,match($A2,'Form Responses 1'!$A$2:$A,0),match(I$1,'Form Responses 1'!$A$1:$DY$1,0))
However, this piece is the problem piece:
match(I$1,'Form Responses 1'!$A$1:$DY$1,0)
This is because I$1 appears 4 times in range Form Responses 1'!$A$1:$DY$1. The one that I want is the one that does not return a empty cell when nested in index() function.
I've made a more simple case when all the data is on single sheet.
The formula is:
=QUERY(TRANSPOSE({A1:E1;FILTER(A2:E8,A2:A8 = 2)}),
"select Col2 where Col2 is not null and Col1 = 'foo' limit 1")
number 2 is criteria by row ($A2 in your sample)
text foo is criteria by column ( replace it with " & I$1 & " )
How it works
{A1:E1; filter } is to get headers and desired row in one array
TRANSPOSE is to use query
where Col2 is not null is to get rid of empty cells
limit 1 is like select first 1
I have this formula in my sheet:
=query('Character Analysis'!$H62:$L83,"select H,I,J,K,L where H is not null order by L DESC",0)
Only the first two of the source rows have data in them, but on the sheet with the query formula it appears to be pulling all the rows in the range, even the blank ones. If I type something in the 3rd row on the query formula sheet, it gives me an error saying "Array result was not expanded because it would overwrite data in ________." But it doesn't need that room because there are only two rows of data in the query result.
I tried adding the "is not null" language in hopes that it would limit the returned result to only filled cells, but it's not working.
How can I tell my query to only pull data from filled cells in the source range?
I figured out a workaround, at least to the degree that it works for me. It's not a true answer as I'd still like to know why the "is not null" language isn't working, but this is giving me exactly what I need: You can just limit the number of returned rows to the number of source rows with data by counting them:
=query('Character Analysis'!$H62:$L83,"select H,I,J,K,L order by L DESC limit "&COUNT('Character Analysis'!$L62:$L83)&"",0)
According to source
You can:
Using a ‘where’ clause to eliminate blank rows
If a named range is defined using entire column (ie including blank rows) you may find these blanks appear in the query result (which, depending on the sort order, could be at the top!). To stop these appearing include a where clause using this syntax (assuming column A):
"...where A <> ' ' " (for text fields)
"...where A <>0" (for numeric fields)
This means ‘where values in column a are not zero-length text.
I am trying to conditionally format a row in Google Sheets based on the result of a QUERY operation. I can get the QUERY to return the value I want (either 0 or non-zero), however QUERY insists on returning a header row.
Since the QUERY now takes up 2 rows for every row of data, changing the format of the row based off the QUERY result starts to get weird after just a few rows.
The problem I am ultimately trying to solve in the case where I enter a list of names, and I want to compare each name to a list of "NSF Names". If a name is entered, and it exists on the NSF list, I would like to flag the entry by highlighting the row red.
Help is greatly appreciated.
Edit: Formula, as requested:
=query(A:D,"select count(A) where C contains '"&E1&"' and D contains '"&E2&"'")
A:D is the data set (A is a numeric ID, B is full name, C and D are first and last names respectively).
E1 and E2 are placeholders for the person's first and last name, but would eventually be replaced with parsing the person's name, as it's inputted on the sheet (TRIM(LEFT(" ", A2) etc...)
I can get the QUERY to return the value I want (either 0 or non-zero),
however QUERY insists on returning a header row.
There might be better ways to achieve what you want to do, but in answer to this quote:
=QUERY(A:D,"select count(A) where C contains '"&E1&"' and D contains '"&E2&"' label count(A) ''")
A query seems a long-winded approach (=countifs(C1:C7,E$1,D1:D7,E$2) might be adequate) but the label might be trimmed off it by wrapping the query in:
index(...,2)