Query with array in condition in Google Sheet - google-sheets

I have 2 tabs:
Overview with the list of tasks and columns per each day when they should be done. The task can be open or completed several times.
Wall of shame - it should consist of Open tasks which deadline is over. The deadline should be filled in from line 1 in the Overview tab. If the task is overdue several times it should be specified as a new line with the new deadline.
I need help with the formula for "Wall of shame" tab.
Please see my example - https://docs.google.com/spreadsheets/d/1gaH-XCf9JtM0C2pJU9EidOk1hsLhmZ5J_b-5_0JUgyc/edit#gid=113767391

Try this in cell A1, deleting everything else in the 'Wall of Shame' sheet:
=arrayformula(
query({"Department"\"Activity"\"Owner"\"Deadline"\"Date open"\"Overdue, days";
query({
flatten(split(rept("|"&Overview!A2:A;columns(query(iferror(split(flatten(trim(query(transpose(if(Overview!F2:AA="Open";if(Overview!F1:AA1<=today();Overview!F$1:AA$1;);));"";9^9)));" "););"";0)));"|"))\
flatten(split(rept("|"&Overview!B2:B;columns(query(iferror(split(flatten(trim(query(transpose(if(Overview!F2:AA="Open";if(Overview!F1:AA1<=today();Overview!F$1:AA$1;);));"";9^9)));" "););"";0)));"|"))\
flatten(split(rept("|"&Overview!C2:C;columns(query(iferror(split(flatten(trim(query(transpose(if(Overview!F2:AA="Open";if(Overview!F1:AA1<=today();Overview!F$1:AA$1;);));"";9^9)));" "););"";0)));"|"))\
flatten(split(rept("|"&Overview!E2:E;columns(query(iferror(split(flatten(trim(query(transpose(if(Overview!F2:AA="Open";if(Overview!F1:AA1<=today();Overview!F$1:AA$1;);));"";9^9)));" "););"";0)));"|"))\
flatten(query(iferror(split(flatten(trim(query(transpose(if(Overview!F2:AA="Open";if(Overview!F1:AA1<=today();Overview!F$1:AA$1;);));"";9^9)));" "););"";0))\
if(flatten(query(iferror(split(flatten(trim(query(transpose(if(Overview!F2:AA="Open";if(Overview!F1:AA1<=today();Overview!F$1:AA$1;);));"";9^9)));" "););"";0))<>"";today()-flatten(query(iferror(split(flatten(trim(query(transpose(if(Overview!F2:AA="Open";if(Overview!F1:AA1<=today();Overview!F$1:AA$1;);));"";9^9)));" "););"";0));)
};"where Col6 is not null ";0)};
"select Col1,Col2,Col3,Col4,Col5,Col6";1))
I've put the whole thing in a query so you can decide which columns you want to select, ie, you could adapt to select Col1,Col2,Col3,Col4,Col6

Related

Query Function, Timesheet Data Viz

I'm working on a timesheet dashboard for my office. My goal is to create summaries of weekly, monthly and yearly time spent on overhead vs. projects. I have based the formula on Player0's work that organize the data into weekly, monthly, and yearly results (all hours added up). I do not know how to separate overhead work from time on project work. Sample Sheet:
https://docs.google.com/spreadsheets/d/1IRtS60P256_fo-Yen1IKV4U6SkNpZJWc1Cf8Jeqw_20/edit?usp=sharing
Desired Output: Please refer to Sample Sheet, Dashboard tab, for example.
Generating TOTAL HRS should be simple in a Query function, by adding up OVHD HRS + PROJ HRS columns (once created).
Generating % PROJ HRS should be simple in a Query function with basic athematic.
What would we use to generate OVHD HRS and PROJECT HRS as new columns?
Thank you in advance for your insights.
Player0's post: Sort timesheet logged hours by week
I've tried using SUMIF function to create the additional columns within Query, but get an error (number of rows doesn't match...).
The one formula which do everything is here.
put the formula into C2 as shown in the images.
in A3, select in which method do you want to display the results.
in A4, select in which staff do you want to display the results.
This formula mainly uses QUERY() to modify data from the given range, togather with some other date functions.
=ArrayFormula(LAMBDA(SHOW,STAFF,
LAMBDA(RANGES,
LAMBDA(HEADERS,JBRAW,FFRAW,TGRAW,
LAMBDA(DATARAW,
LAMBDA(YEARS,MONTHS,MONTHLY,WEEKS,WEEKNUMS,TYPES,
LAMBDA(DATA,
LAMBDA(SHOWWEEK,ORDER,
LAMBDA(RESULT,
QUERY(IF(RESULT="",0,RESULT),"SELECT Col1,Col2,Col3,Col2+Col3,(Col3/(Col2+Col3)) LABEL Col2+Col3'TOTAL HRS',(Col3/(Col2+Col3))'% PROJ HRS' FORMAT (Col3/(Col2+Col3))'#,##0.00 %'",1)
)(QUERY(QUERY(QUERY(DATA,"SELECT "&SHOW&",SUM(Col6) "&SHOWWEEK&" WHERE Col2='"&STAFF&"' GROUP BY "&SHOW&SHOWWEEK&" PIVOT Col1",1),"ORDER BY "&ORDER,1),"SELECT Col1,Col2,Col3",1))
)(IF(SHOW="Col7",",Col5",""),IFS(SHOW="Col7","Col4 DESC",SHOW="Col8","Col1 ASC",TRUE,"Col1 DESC"))
)(QUERY({DATARAW,YEARS,MONTHS,WEEKS,WEEKNUMS,TYPES,MONTHLY},"SELECT Col10,Col1,Col6,Col7,Col8,Col5,Col9,Col11 LABEL Col6'YEAR',Col7'MONTHS',Col8'WEEKS',Col9'WEEK',Col11'MONTH'",1))
)(
YEAR(INDEX(DATARAW,,4)),
MONTH(INDEX(DATARAW,,4)),
TEXT(INDEX(DATARAW,,4),"mmmm"),
WEEKNUM(INDEX(DATARAW,,4)),
IFERROR("WEEK "&WEEKNUM(INDEX(DATARAW,,4))&" "&YEAR(INDEX(DATARAW,,4)),""),
IFS(INDEX(DATARAW,,2)="PROJECT #","TYPE",INDEX(DATARAW,,2)=0,"OVHD",INDEX(DATARAW,,2)>0,"PORJ")
)
)({HEADERS;JBRAW;FFRAW;TGRAW})
)(
ARRAY_CONSTRAIN(RANGES,1,5),
QUERY(RANGES,"SELECT "&JOIN(",","Col"&SEQUENCE(5,1,1))&" WHERE Col1 IS NOT NULL LABEL "&JOIN(",","Col"&SEQUENCE(5,1,1)&"''")),
QUERY(RANGES,"SELECT "&JOIN(",","Col"&SEQUENCE(5,1,7))&" WHERE Col7 IS NOT NULL LABEL "&JOIN(",","Col"&SEQUENCE(5,1,7)&"''")),
QUERY(RANGES,"SELECT "&JOIN(",","Col"&SEQUENCE(5,1,13))&" WHERE Col13 IS NOT NULL LABEL "&JOIN(",","Col"&SEQUENCE(5,1,13)&"''"))
)
)(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1IRtS60P256_fo-Yen1IKV4U6SkNpZJWc1Cf8Jeqw_20/edit#gid=1822160043","'D_Transpose'!A:Q"))
)(IFS($A$3="Weekly","Col7",$A$3="Monthly","Col8",$A$3="Yearly","Col3"),$A$4))

Google sheets: Is there a way to quickly/easily add a date range to ~300 cells each with different countifs formulas?

I am using the countifs function to add up a lot of different conditions - I need help to simplify the process so that it doesn't require so much manual formatting every time.
Here is a screenshot of a hypothetical spreadsheet. Here is a hypothetical scenario that will help convey my question. Let's say I am working with 3 clients, Macy's, abercrombie, and gap, to fill several open positions. We are reviewing multiple candidates. When I have reviewed them and approved, I select "yes" in the verdict column (E). When they have been processed, I selected yes in the F column. If I do not approve them, I select No in the column. So on and so forth.
So now I'd like to keep track of how many candidates I've approved and processed for each client for each open position. Here is my spreadsheet for that. I have used the countifs function from the previous spreadsheet, called "Review Document" as follows:
Column C, Row 2 - counting sales associate for abercrombie who have been approved and not yet processed:
=COUNTIFS(
'Review Document'!$B:$B,"abercrombie",
'Review Document'!$C:$C, "sales associate",
'Review Document'!$E:$E,"yes",
'Review Document'!$F:$F,"no")
I essentially do this for every single client, for every single role, for both column C and D. Imagine that there are ~300 rows with different companies and roles - The formula text changes every time to count if "position" and "company".
What I would like to do is now find an easy way to automatically apply a date range to all of these cells, without having to manually add a date criterion for every single formula. For example, in the first spreadsheet, there are dates in Feb, Mar, And April. Is there a way to apply a date range on my second spreadsheet so that it only counts the dates I specify? E.G. - apply some date range to ALL cells in that sheet so that it only counts if the date is 2/15/2022-3/31-2022? I would ultimately like to be able to change the date range quickly without having to manually add a date criterion to 300 cells, and then change it every time I want to see the numbers for a different date range. I was tinkering with conditional formatting but I haven't figured it out.
Thanks!
use:
=INDEX(QUERY(QUERY({A2:A, PROPER(B2:C),
IF((E2:E="yes")*(F2:F<>"yes"), 1, 0),
IF((E2:E="yes")*(F2:F= "yes"), 1, 0)},
"select Col2,Col3,sum(Col4),sum(Col5)
where Col1 is not null "&
IF(J1="",," and Col1 >= date '"&TEXT(J1, "yyyy-mm-dd")&"'")&
IF(J2="",," and Col1 <= date '"&TEXT(J2, "yyyy-mm-dd")&"'")&"
group by Col2,Col3"),
"offset 1", ))

Finding duplicates across range and summing it up

I have a list of agents who are working on OT, but the challenge is that they have 2 entries for OT per day, and when i need to work on this data with another sheet i have to sort out the data and remove duplicates manually in order not to cause issues with vlookup.
I need the end result to be like this:
if any agents works OT 2 times a day then sum it up and place in one raw with the date.
i have made helpers columns to show the duplicates but the i got stuck with the next steps
here is the sheet for the example:
https://docs.google.com/spreadsheets/d/1rdqylI9Rr4CxPIJcffEsqfoHx0loPVrqi2UJAQ30Sos/edit#gid=0
use:
=QUERY(A2:C, "select A,B,sum(C) where C is not null group by A,B label sum(C)''")
and vlookup from it...

Arrayformula Filter but with dynamic values Google Sheets

Here is what I'm trying to do in this sheet:
https://docs.google.com/spreadsheets/d/1uK7poWPaGvIR_v-7eiD84zdMXu6AFNJqSZWJff6FxiY/edit?usp=sharing
In "Task Tracker" tab, team members write tasks, hours they did in that task and a count of that task.
In "Sheet1" tab, the tasks are automatically populated in the "Tasks This Week" section, and then those are chooseable as drop downs in the "Tasks" section. (This drop down is needed for something I'm building later to keep values in the cells consistent).
The trouble now is that I want to have the "Hours" and "Count" of Monday, Tuesday, Wednesday etc populate automatically based off of the values entered in the "Task Tracker" sheet. But, given that week-by-week, the values (name of tasks) may change, new tasks will arise, I don't have a static value I can filter by.
Is there a way I can use arrayformula+filter to do this, or another function? I want Monday, Tuesday, etc's "Hours" and "Count" in "Sheet 1" to populate automatically, tallying all of the values in the "Task Tracker" tab based off what task is selected in the drop down in the "Tasks" section of Sheet1.
We can simply take the value of the "Tasks" column and filter the values in our Task Tracker sheet with that specific task.
The rest is syntactic sugar to make sure we deal with empty cells, tasks that don't occur within the Task Tracker even once, and making sure the correct rows and columns are dynamic/static for easy adjustments as we fill out each day.
Here's the code:
=IF(
ISBLANK($A6),
"",
IFERROR(
SUM(
FILTER('Task Tracker'!D$3:'Task Tracker'!D$32,
'Task Tracker'!$B$3:'Task Tracker'!$B$32 = $A6)
),
0
)
)
And here's the sheet:
https://docs.google.com/spreadsheets/d/1yqg07r0q-2i24Wpv8AQhJjP39uynVBQCJGKEROsp6vM/edit?usp=sharing

Display Rows From Another Sheet Based On Range Of Dates

I'll try to explain this as best as I can, I'm not super experienced with spreadsheet formulas so bear with me.
Currently I have 2 Google spreadsheets, one contains a list of all client related tasks. The second spreadsheet is client specific, it has a few sheets such as "Feeder", "Archived Requests", "Monthly Report". The "Archived Requests" sheet lists all the data assigned to a specific client from my first spreadsheet using QUERY IMPORTRANGE:
=Query(IMPORTRANGE("key","spreadsheet-name!A:Z"),"Select Col2, Col3, Col4, Col5 where Col1 contains 'TOSC'",1)
This part works all fine and good.
My "Feeder" sheet lists some =DATE and =EOMONTH formulas which I have made into Named Ranges.
What I'd like to do, ideally, is display all data from the "Archived Requests" sheet on the "Monthly Report" sheet between the named range "ReportMonthStart" and "PriorMonthStart".
Essentially, what I'm hoping to achieve is a dynamic listing of row data that goes back 30 days from the 15th of each month.
I'm not sure if this should/can be done with a Query or a Filter, or any other formula.
Here is the link to my current spreadsheet.
The filter does this nicely:
=filter('Archived Requests'!A2:E, ('Archived Requests'!A2:A >= PriorMonthStart) * ('Archived Requests'!A2:A <= ReportMonthStart))
This returns A-E entries of the rows where A column is between PriorMonthStart and ReportMonthStart. Multiplication of two conditions is logical AND.

Resources