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)
Related
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.
Columns D:H show my initial info, where two workstreams (Column D) have different issues occur (Column F:H). These issues fall under one of three categories, under Columns A:B. I want the chart to show the count of the category each issues falls under, making sure it's also showing that it's within a certain workstream.
what i was working with so far is below to match issues to the three categories
=INDEX(A:B, MATCH(F1, A:A, 0), 2)
and below to count the times a value is within the workstream group (A or B).
=countif(flatten(filter(F:H,D:D="A")),"one")
How can I combine these two?
https://docs.google.com/spreadsheets/d/1hs-Srt-qdOR44V_rmvKF-rC5DThRrQrrCfiA_jAvnH0/edit?usp=sharing
delete J:M range and use in D1:
=INDEX({QUERY(SPLIT(FLATTEN(D1:D9&"×"&VLOOKUP(F1:H9, A1:B12, 2, 0)), "×"),
"select Col1,count(Col1) where Col2 is not null
group by Col1 pivot Col2 label Col1'workstream'"); "TOTAL",
TRANSPOSE(MMULT(1*QUERY(
QUERY(SPLIT(FLATTEN(D1:D9&"×"&VLOOKUP(F1:H9, A1:B12, 2, 0)), "×"),
"select count(Col2) where Col2 is not null
group by Col2 pivot Col1"), "offset 1", ),
SEQUENCE(COUNTUNIQUE(D1:D9), 1, 1, 0)))})
formula explanation
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)), "×")))
I need to combine duplicate rows then concatenate values in column 2 and sum values in column 3, if row does not have duplicate retain values. I'm using Excel 2010.
Given;
Col1 Col2 Col3
Apple Red 2
Apple Green 5
24829 sk1 2
24829 sd2 8
123 po3 1
Bag black 7
Expected Output:
Col1 Col2 Col3
Apple Red,Green 7
24829 sk1,sd2 10
123 po3 1
Bag black 7
With Google Sheets you could try:
Col G:=unique(A2:A)
Col H:=join(",",filter(B2:B,A2:A=G2))
Col I:=sumif(A2:A,G2,C2:C)
use this one-cell solution:
=ARRAYFORMULA({UNIQUE(INDIRECT("A1:A"&COUNTA(A1:A))),
REGEXREPLACE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(IF(QUERY(QUERY(""&A1:B,
"select count(Col1) where Col1 is not null group by Col1 pivot Col2", 0),
"offset 1", 0)<>"", QUERY(""&A1:B,
"select count(Col1) where Col1 is not null group by Col1 pivot Col2 limit 0")&",", ))
,, 999^99))), ",$", ), QUERY({""&A1:A, C1:C},
"select sum(Col2) where Col1 is not null group by Col1 label sum(Col2)''", 0)})
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)))