I have a transaction table and I need to show open balances for it.
I didn't find how to hide empty rows. I want to show just GREEN rows. I tried to use filter but it doesn't work
Test sheet
try:
=ARRAYFORMULA({QUERY(REGEXREPLACE(""&QUERY(A1:D,
"select A,B,sum(D) where A is not null group by A,B pivot C"),
"^0$", ),
"where Col3 is not null or Col4 is not null");
{"Grand Total", "", INDEX(QUERY(A1:D,
"select sum(D) where A is not null pivot C"), 2)}})
Related
Since Query is such a powerful formula, i try to avoid my team members to avoid messing up the pivot. I try to to come out with query to replace my pivot. Based on the raw data Google Sheet Trix, i try to sum column based on the criteria i have described in Grey colour (B2:E2). Appreciate if someone could lay some foundation for me, so i can further tweaks based on the formula you create here.
I created a new tab and entered the following in cell A1:
=query(
{'RAW DATA'!B:B,'RAW DATA'!E:E,'RAW DATA'!G:J},
"select Col1, sum(Col3), sum(Col4), sum(Col5), sum(Col6)
where Col1 is not null and Col2<>'Black and Yellow'
group by Col1"
)
Use a query() with a group by clause, like this:
=query(
'RAW DATA'!B1:J,
"select B, sum(G), sum(H), sum(I), sum(J)
where B is not null and E <> 'Black' and E <> 'Yellow'
group by B",
1
)
The result table will only include weeks where there is at least one data row where E is not Black or Yellow.
See the new Solution sheet in your sample spreadsheet.
Here is your solution. which also included in new tab named Solution Pivot in Query.
=ArrayFormula(QUERY(SPLIT(FLATTEN(TO_TEXT('RAW DATA'!B2:B)&"|"&'RAW DATA'!E2:E&"|"&'RAW DATA'!G1:J1&"|"&'RAW DATA'!G2:J),"|"),"Select Col1, Sum(Col4) where Col2 is not null And Col2 <> 'Yellow' And Col2 <> 'Black' Group by Col1 Pivot Col3 label Col1 'Date'"))
I have a spreadsheet where users fill out a form, they have multiple options they can pick by clicking the checkboxes.
The responses sheets looks like this
I want to filter the results by option, so my main goal is to get the total amount of options selected:
I've been trying with COUNTIF but it's not working because I'm not selecting the specific response
=COUNTIF('Form Responses 1'!C2:F4,"*"&$B$1&"*")
I'm assuming I need to add a VLOOKUP but I'm not sure how to match it with the option
Here's a spreadsheet to play around with it
try:
=INDEX({QUERY(TRIM(SPLIT(FLATTEN(A2:A&"×"&SPLIT(B2:B, ",")), "×")),
"select Col1,count(Col1) where Col2 is not null group by Col1 pivot Col2 label Col1 'Person'");
{"Total", TRANSPOSE(MMULT(TRANSPOSE(QUERY(QUERY(TRIM(SPLIT(FLATTEN(A2:A&"×"&SPLIT(B2:B, ",")), "×")),
"select count(Col1) where Col2 is not null group by Col1 pivot Col2"), "offset 1", )*1),
SEQUENCE(COUNTUNIQUE(TRIM(FLATTEN(SPLIT(TEXTJOIN(",", 1, B2:B), ",")))), 1, 1, )))}})
Perhaps a formula like this:
=IFNA(QUERY({$A$2:$A$6, $B$2:$B$6}, "Select 1 where Col2 contains '"&B$9&"' and Col1 = '"&$A10&"' order by Col1 label 1 ''"), 0)
This outputs a 1 if the referenced cell contains the specified text, and a 0 otherwise. See the docs for the Query Function and the Query Language for more information.
I have a list of sessions, I want to be able to import the ones that have been rescheduled (along with the new rescheduled session) to another sheet. So under colC one will say 'Rescheduled' and the other will say 'Attended'. So what I'd like to do is grab the participant name, but only if it shows up more than once, so I'd get both the rescheduled session and the new session. I tried using importrange and query, but couldn't quite get it right. How can I do this?
https://docs.google.com/spreadsheets/d/10ZWcO9DeBx6KjiyvFvcoBlGk7yw2b8z2gFPi26orOGc/edit?usp=sharing
try:
=INDEX(REGEXEXTRACT(FLATTEN(QUERY(QUERY(TRANSPOSE(QUERY(TRANSPOSE(QUERY({
IMPORTRANGE("10ZWcO9DeBx6KjiyvFvcoBlGk7yw2b8z2gFPi26orOGc", "Sheet1!A1:C"),
FLATTEN(QUERY(TRANSPOSE(
IMPORTRANGE("10ZWcO9DeBx6KjiyvFvcoBlGk7yw2b8z2gFPi26orOGc", "Sheet1!A1:C")),,9^9))},
"select max(Col4) where Col1 is not null group by Col2 pivot Col3")),
"where Col1 matches 'Rescheduled|Attended'", )),
"where Col1 is not null and Col2 is not null"),
"offset 1", )),
"(\d+/\d+/\d+) (.*) (Att.*|Res.*)"))
Formula Explanation:
Take the IMPORTRANGE
Merge all columns into one column
Create a virtual array {}
Pass into QUERY and pivot the data
Transpose the result
Use query to get only needed columns
Transpose back
Compare 1st and 2nd columns and remove
Remove header row
Flatten data into one column and split into the 3 needed columns
and if that's not enough:
=INDEX(REGEXREPLACE(SORT(TEXT(REGEXEXTRACT(FLATTEN(
QUERY(QUERY(TRANSPOSE(QUERY(TRANSPOSE(QUERY({
IMPORTRANGE("10ZWcO9DeBx6KjiyvFvcoBlGk7yw2b8z2gFPi26orOGc", "Sheet1!A1:C"),
FLATTEN(QUERY(TRANSPOSE(
IMPORTRANGE("10ZWcO9DeBx6KjiyvFvcoBlGk7yw2b8z2gFPi26orOGc", "Sheet1!A1:C")),,9^9))},
"select max(Col4) where Col1 is not null group by Col2 pivot Col3")),
"where Col1 matches 'Rescheduled|Attended'", )),
"where Col1 is not null and Col2 is not null"),
"offset 1", )),
"(\d+/\d+/\d+) (.*) (Att.*|Res.*)"), {
"yyyymmdd\×m/d/yyyy", "#", "#"}), 2, 0, 1, 1), "^(\d+×)", ))
demo sheet
have data like this
and want result like this
using this formula:
=ARRAYFORMULA(REGEXREPLACE(TRIM(SPLIT(TRANSPOSE(QUERY(QUERY(
IF(D2:D<>"", {C2:C&"♠", D2:D&","}, ),
"select max(Col2) where Col1 is not null group by Col2 pivot Col1")
,,999^99)), "♠")), ",$", ))
make the result like this
Can someone figure it out, How to fix this formula?
Thanks
I have a column of search terms and would like to find out all the two-word phrases in this column and the frequency of each of all them. Does anyone know of a formula in Google Sheets that can help me accomplish this?
=ARRAYFORMULA(IFERROR(QUERY(IF(SPLIT(A1:A, " ")>0, A1:A, ),
"select Col2,count(Col2)
where Col2 is not null
and Col3=''
group by Col2
label count(Col2)'frequency'"),
QUERY(IF(SPLIT(A1:A, " ")>0, A1:A, ),
"select Col2,count(Col2)
where Col2 is not null
group by Col2
label count(Col2)'frequency'")))
pste in C2 and drag down:
=COUNTA(FILTER(A:A, SEARCH("*"&B2&"*", A:A)))