Home > Net >  Query with array in condition in Google Sheet
Query with array in condition in Google Sheet

Time:09-18

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

CodePudding user response:

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