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")
Related
I'm obtaining a list of unique values with this formula:
=ArrayFormula(VLOOKUP(UNIQUE(REGEXEXTRACT(FILTER(A2:A1000,A2:A1000<>""),"\d+"))&"*",REGEXEXTRACT(A2:A1000,"\d+.+$"),1,FALSE))
I did this for 3 different sheets, in each sheet has different values but in some cases these are repeated across the sheets like this:
These are the final list after the formula:
After this I used this formula
=COUNTIF(Sheet3!$A$2:$A$500,A2)+COUNTIF(Sheet4!$A$2:$A$500,A2)+COUNTIF(Sheet5!$A$2:$A$500,A2)
I get this:
Actually it works as I want but is not a dynamic function I would like to have the list of the unique values and the times appearing across the sheets if is possible
Here is the problem with some text in the row that I have with []
Use below QUERY() formula-
=QUERY({Sheet3!A:A;Sheet4!A:A;Sheet5!A:A},"select Col1, Count(Col1)
where Col1 is not null
group by Col1
label Col1 'List of Values', Count(Col1) 'Count'")
I have a table with first row as header and first column as week number, I need to sum all the data on every week that meets the criteria depending on the header name.
This formula only filter by header and week, but I can't summarize the data, I would like that the formula is "dynamic" because the header name section can change:
=QUERY(TRANSPOSE(A1:AA23),"SELECT * WHERE Col1 = 'M.O.'",1)
This is an example spreadsheet, at the end is the desired result:
LINK TO EXAMPLE SHEET
use:
=INDEX(QUERY(SPLIT(FLATTEN(IF(D2:24="",,D1:1&"×"&A2:A24&"×"&D2:24)), "×"),
"select Col1,sum(Col3)
where Col1 matches 'INDIRECTO|M.O.'
group by Col1
pivot Col2"))
I have a set of data where an account id can have multiple rows of country. I'm looking for an array function that will give me a unique list of accounts with the countries in the second column as csv values e.g. country1,country1,country3.
If I unique the accounts, this query will do it per row but I'm really looking for an array so I don't have to maintain it as the number of rows grows.
=TEXTJOIN(",",1,UNIQUE(QUERY(A:B,"select B where A = '"&D2&"'",0)))
I have a sample sheet here.
try:
=INDEX(REGEXREPLACE(TRIM(SPLIT(FLATTEN(QUERY(QUERY(
IF(A2:A="",,{A2:A&"×", B2:B&","}),
"select max(Col2)
where not Col2 matches '^×|^$'
group by Col2
pivot Col1"),,9^9)), "×")), ",$", ))
I want to update multiple columns in same update statement with one column depends upon another new column new value.
Example:
Sample Data: col1 and col2 is the column names and test_update is the table name.
SELECT * FROM test_update;
col1 col2
col-1 col-2
col-1 col-2
col-1 col-2
update test_update set col1 = 'new', col2=col1||'-new';
SELECT * FROM test_update;
col1 col2
new col-1-new
new col-1-new
new col-1-new
What I need to achieve is col2 is updated as new-new as we updated value of col1 is new.
I think may be its not possible in one SQL statement. If possible How can we do that, If its not What is best way of handling this problem in Data Warehouse environment, like execute multiple update 1st on col1 and then on col2 or any other.
Hoping my question is clear.
You cannot update the second column based on the result of updating the first column. However this can be achieved in a single by "pre-calculating" the result you want and then updating based on that.
The following update using a join is based on the example provided in the Redshift documentation:
UPDATE test_update
SET col1 = precalc.col1
, col2 = precalc.col2
FROM (
SELECT catid
, 'new' AS col1
, col1 || '-new' AS col2
FROM test_update
) precalc
WHERE test_update.id = precalc.id;
;
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