Combining multiple cell values on Google Sheets - google-sheets

Is there any way in Google Sheets to automatically change cells from the current format to intended format like in this screenshot:

=ARRAYFORMULA(REGEXREPLACE(TRIM(SPLIT(TRANSPOSE(SPLIT(
CONCATENATE(TRANSPOSE(QUERY({"♦"&A1:A&"♠", B1:B&", "},
"select max(Col2) where Col2 is not null group by Col2 pivot Col1", 0))),
"♦")), "♠")), ",$", ))

Related

How to count values if option checked is selected in one cell

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.

Combining rows based on IDs on 2 columns Formula in Google Sheets

I have data that looks like this:
And I want it to look like this:
Formula ideas?
Thanks!
Maria
try:
=ARRAYFORMULA(TRIM(SPLIT(FLATTEN(QUERY(TRANSPOSE(QUERY(QUERY({A2:A&"×"&B2:B,
TRIM(FLATTEN(QUERY(TRANSPOSE({"×"&C2:D}),,9^9))),
TRIM(FLATTEN(QUERY(TRANSPOSE(C2:D),,9^9)))},
"select Col1, max(Col2) where Col3 is not null group by Col1 pivot Col3"),
"offset 1", 0)),, 9^9)), "×")))

Google Sheets Text Join to join character from columns into row

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

Sort timesheet logged hours by week

So I have a timesheet for a project I'm working on, and I'd like to see how many hours I've worked by week.
I found an answer from this post: Create Weekly/Monthly/Yearly line chart in Google Sheets to sum amounts within same week/month/year range which got me really far.
Monthly and Yearly queries are working great thanks to user player0. However, weekly sorting is borked for me. The code I'm using now comes from that post:
=ARRAY_CONSTRAIN(ARRAYFORMULA(
IF(J2="Weekly", QUERY({"week "&WEEKNUM(A2:A)&" "&YEAR(A2:A), E2:E, YEAR(A2:A)+WEEKNUM(A2:A)*0.083},
"select Col1,sum(Col2),Col3 where Col2 is not null group by Col1,Col3 order by Col3 label sum(Col2)''", 0),
IF(J2="Monthly", QUERY({TEXT(A2:A, "mmmm")&" "&YEAR(A2:A), E2:E, YEAR(A2:A)+MONTH(A2:A)*0.083},
"select Col1,sum(Col2),Col3 where Col2 is not null group by Col1,Col3 order by Col3 label sum(Col2)''", 0),
IF(J2="Yearly", QUERY({YEAR(A2:A), E2:E},
"select Col1,sum(Col2) where Col2 is not null group by Col1 label sum(Col2)''", 0), )))), 999^99, 2)
Here's what the sheet looks like
I know very little about Google Sheets, so you'll have to keep it simple for me XD
try:
=ARRAY_CONSTRAIN(ARRAYFORMULA(
IF(J2="Weekly", QUERY(QUERY({"week "&WEEKNUM(A2:A)&" "&YEAR(A2:A), E2:E, "w"&YEAR(A2:A)&TEXT(WEEKNUM(A2:A), "00")},
"select Col1,sum(Col2),Col3 where Col2 is not null group by Col1,Col3 order by Col3 label sum(Col2)''", 0), "offset 1", 0),
IF(J2="Monthly", QUERY({TEXT(A2:A, "mmmm")&" "&YEAR(A2:A), E2:E, YEAR(A2:A)+MONTH(A2:A)*0.083},
"select Col1,sum(Col2),Col3 where Col2 is not null group by Col1,Col3 order by Col3 label sum(Col2)''", 0),
IF(J2="Yearly", QUERY({YEAR(A2:A), E2:E},
"select Col1,sum(Col2) where Col2 is not null group by Col1 label sum(Col2)''", 0), )))), 999^99, 2)

How can I extract multiple values based on one criterion?

I currently have a database that looks like this:
But I would like for the output of the database to look like this:
I have tried using INDEX MATCH but I haven't been able to find a way to exclude blank values from the output.
A formula I have used but have not exactly returned the expected output is:
=INDEX('Input sheet'!B2:I7,0,MATCH(A2,'Input sheet'!A2:A7,0))
Is there a formula that can return non-blank values in a row, as shown on the output sheet?
https://docs.google.com/spreadsheets/d/1HdkBPhzB5oZ0RyKZzAOkPIXT81upgHiGBLfgXsrOZDI/edit?usp=sharing
=ARRAYFORMULA({UNIQUE(FILTER('Input sheet'!A2:A, 'Input sheet'!A2:A<>"")), TRIM(SPLIT(
TRANSPOSE(QUERY(IF(QUERY(QUERY(TRIM(SPLIT(TRANSPOSE(SPLIT(QUERY(TRIM(TRANSPOSE(QUERY(
TRANSPOSE(IF(LEN('Input sheet'!B2:J), "♠"&'Input sheet'!A2:A&"♦"&'Input sheet'!B1:J1, ))
,,999^99))),,999^99), "♠")), "♦")),
"select count(Col2) where Col2 is not null group by Col2 pivot Col1",0), "offset 1",0)<>"",
QUERY(QUERY(TRIM(SPLIT(TRANSPOSE(SPLIT(QUERY(TRIM(TRANSPOSE(QUERY(
TRANSPOSE(IF(LEN('Input sheet'!B2:J), "♠"&'Input sheet'!A2:A&"♦"&'Input sheet'!B1:J1, ))
,,999^99))),,999^99), "♠")), "♦")),
"select Col2,count(Col2) where Col2 is not null group by Col2 pivot Col1", 0),
"select Col1 offset 1", 0)&"♥", ),,999^99)), "♥"))})
REVERSE OF ABOVE:
=ARRAYFORMULA(TRANSPOSE(QUERY(SPLIT(TRANSPOSE(SPLIT(TRIM(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(LEN('Output sheet'!B2:F), "♠"&'Output sheet'!A2:A&"♦"&'Output sheet'!B2:F, ))
,,999^99)),,999^99)), "♠")), "♦"),
"select Col2,count(Col2) where Col2 is not null group by Col2 pivot Col1", 0)))

Resources