In column F I have the below formula which references the status of sheet 2 column G. The query formula produces 2 results populating cells F2 & F3. I want an "if" formula that if my query produces 2 cells containing yes, yes then say true but if it produces yes, no then produce false or no, no produce false.
This is the link to the sheet for reference. https://docs.google.com/spreadsheets/d/1C5xWlw9vMZMNhXprSCBZsNp0T9qMxvuooIP8I6JoI2Y/edit#gid=0
delete F2:F range and paste this in F2 cell:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A&E2:E, QUERY({Sheet2!A2:A&Sheet2!B2:B,
IF(Sheet2!G2:G="yes", 1, 0)},
"select Col1,sum(Col2)
where Col1 is not null
group by Col1
label sum(Col2)''"), 2, 0)=2))
if Sheet2 jobs are not always in pairs use:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A&E2:E, QUERY({Sheet2!A2:A&Sheet2!B2:B,
IF(Sheet2!G2:G="yes", 1, 0)},
"select Col1,sum(Col2)
where Col1 is not null
group by Col1
label sum(Col2)''"), 2, 0)=
IFNA(VLOOKUP(A2:A&E2:E, QUERY({Sheet2!A2:A&Sheet2!B2:B,
IF(Sheet2!G2:G="yes", 1, 0)},
"select Col1,count(Col2)
where Col1 is not null
group by Col1
label count(Col2)''"), 2, 0))))
I was able to come up with an answer with collaboration of some awesome people. The way I solved it, for now, is changing the where clause to focus on the "False" response only and wrapping it in an if and iferror to give me the True response
=iferror(ifna(if(query(IMPORTRANGE("https:/...","range"),"select Col8 where Col1 = '"&A7&"' and '"&E7&"' = Col2 and Col8 = 'No'",0)="No",FALSE,TRUE),TRUE),FALSE)
Related
I am trying to piece together a query that does a few things. One, I want it to list out all the names in a column, and two, I only want it to list out the name from that column if it doesn't exist within an array of columns.
=QUERY(QUERY(Breakdown!$A$2:$B), "select Col1 where Col1 != '' and Col2 = 'Warrior' order by Col1 Asc")
I got as far as this, which displays all of the names in the column as I want it to, but when I start adding in 'not in' type parameters, I break it every which way. How do I check that Col1 doesn't exist in the range ='Raid Comp'!A2:Q10?
Here is the spreadsheet: https://docs.google.com/spreadsheets/d/1X0GiOCAAve1CR4A3JG2Ybf-daMvrrhAsZF5V3XEdn4E/edit?usp=sharing
What I am tryin to do is once a name is entered within the colored areas, if name entered exists in the list below the colored area, the name is removed from the list.
Example:
try regex in query:
=QUERY({Breakdown!$A$2:$B},
"select Col1
where Col2 = 'Warrior'
and not Col1 matches '"&TEXTJOIN("|", 1, 'Raid Comp'!A2:Q10)&"'
order by Col1 asc")
I am trying to run а query against several ranges combined with {} like query({A2:C5, if(C1:C5='something',1,0)}, "select ..."). But I am getting an #REF! error with a message Function ARRAY_ROW parameter 2 has mismatched row size. Expected: 4. Actual: 1. What is the reason for that?
Here is a detailed example. Suppose I have a table like that:
id kind color
1 a green
2 a green
3 b green
4 c blue
I want to get a table showing number of cells with green for each kind:
kind color_count
a 2
b 1
c 0
Initially, I tried a query with the where clause for that:
=query(A2:C5, "select B, count(C) where C='green' group by B", -1)
But that does not include the row with zero values. So I tried to add an extra column with values 1 for the green color and 0 otherwise and use SUM over that without the where clause:
=query({A2:C5, if(C2:C5="green", 1, 0)}, "select B, sum(D) group by B", -1)
but that gives the above $REF!
As a workaround I added a column D to the table with the formula
=arrayformula(if(C2:C5="green", 1, 0))
Then the following query works and gives the desired result:
=query(A2:D5, "select B, sum(D) group by B", -1)
But is it possible to avoid this artificial column?
IF returns only 1 cell unless you use ARRAYFORMULA. so the error is on a spot because you have 4 cells on one side and 1 cell on the other side.
try:
=ARRAYFORMULA(QUERY({B:B, IF(C:C="green", 1, 0)},
"select Col1,sum(Col2)
where Col1 is not null
group by Col1
label sum(Col2)''", 0))
My table is as follow
Col1 Col2
11_A 9
12_B 8
13_C 7
14_A 6
15_A 4
The table we need after the query
Col1 Col2 Col3
11_A 0 9
12_B 8 0
13_C 7 0
14_A 0 6
15_A 0 4
My query is
Col3 =
LEFT( 'Table'[Col2],
SEARCH("A", 'Table'[Col1], 0,
LEN('Table'[Col1])
)
)
Go to the query designer Add Column > Custom Column and use the following expression:
Update
You need two expressions (two new columns) for this:
One is:
'Your Column3
=if Text.Contains([Col1], "A") = true then [Col2] else 0
And the second:
'Your Column2
=if Text.Contains([Col1], "A") = false then [Col2] else 0
There are many ways to solve this,
Another easy way I like to do this with no-coding is to use Conditional Columns:
In PBI select Power Query Editor
Select your table on the edge of the screen
Select Add Column tab
Select Conditional Columns...
Name your column
Enter your condition as in the picture
You can add several conditions if you like
Don't forget to format your column to numeric if needed.
see picture
Adding columns using Conditional Column
I have the following spreadsheets. I need to compact the contents of this spreadsheet. I was wondering if it is possible to group similar items such as 1952 and add the numbers in the next column and output something along 5m / 2w or similar? 1951 would be compacted to 9w. This data is constantly changing and new reference numbers are added often.
Sheets doesn't do well adding numbers when they're right next to letters, so you'll need to split those cells into a number column and letter column using left() and right(). Put the number from left() inside the value() function as well so Sheets knows it's a number.
Example sheet
Once you have the helper columns made, you can use query() to consolidate and sum up your values. Query language can get tricky so I recommend the reference page. Once you have the sums and letters spit out, you can concatenate them in another column (J for me).
=ARRAYFORMULA(SUBSTITUTE(TRIM(SPLIT(TRANSPOSE(QUERY(TRANSPOSE({
SORT(UNIQUE(INDIRECT("B2:B"&COUNTA(B2:B)+1)&"♦")),IF(ISNUMBER(
QUERY(QUERY(TO_TEXT(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(QUERY(IFERROR({
B2:B&"♦", REGEXEXTRACT(C2:C, "\d+")*1, REGEXEXTRACT(C2:C, "\d+(.+)")}),
"select Col1,sum(Col2),Col3
where Col3 is not null
group by Col1,Col3
label sum(Col2)''", 0)),,999^99)), "♦")),
"select count(Col1)
group by Col1
pivot Col2", 0), "offset 1", 0)), SUBSTITUTE(
QUERY(QUERY(TO_TEXT(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(QUERY(IFERROR({
B2:B&"♦", REGEXEXTRACT(C2:C, "\d+")*1, REGEXEXTRACT(C2:C, "\d+(.+)")}),
"select Col1,sum(Col2),Col3
where Col3 is not null
group by Col1,Col3
label sum(Col2)''", 0)),,999^99)), "♦")),
"select count(Col1)
group by Col1
pivot Col2", 0), "limit 0", 1), " ", ), )}),,999^99)), "♦")), " ", " / "))
spreadsheet demo
below is an example document I have shared:
https://docs.google.com/spreadsheets/d/1WuQIqn8DA12R0mNFGMdjJahQ0eNoxKODpSwopk7KoYU/edit#gid=0
My data is simple table:
I want to do the following:
For starting cell K7 on patient tab
I want to query the call log tab for
two main conditions.
Query select loqic: return rows D,E,F,A when certain conditions are met:
if text colC equals text in patient tab cell c7 AND col D says "No beds Available" And colI shows time left to calling greater than 0
OR If not than:
if col B=cell H3 in patient tab, and Col C= Cell C7 in patient tab
Thank you for your help
My example could help you.
Suppose you have a small data, like this, columns A:D:
Then you may use query state with two or more OR conditions, but insert them into parentheses. Sample formula:
=QUERY({A:D},"select Col1, Col2, Col3, Col4 where (Col1 < 7 and Col3 = 'c') or (Col2 = 'a' and Col4 > 0)")
To use Col1, Col2, Col3... notation inside query, data must be inside {}