Gantt Chat With Google Sheets [duplicate] - google-sheets

I'm trying to make a dally dynamic Gantt chart that takes into account that some of my workdays are not full workdays. For example, if Fridays and Saturdays are both half workdays and Sunday is a non-working day, a three full workdays task that starts on a Monday will be finished on Wednesday. But if the same task starts on a Friday, it will be finished on the consecutive Tuesday. So that the same three full workdays task can fill between three to five days on the Gantt chart.
How can I make this work dynamically on a Google Sheet (or Excel) Gantt chart? Can I make a function that receives the beginning date for a task, takes into accounts all my constraints (for example, Friday is a half-day), and calculates how many days should be filled in the Gantt chart?
Will it be possible to use a higher resolution like a subunit of 1/3 workday?
Attached:

Here is a formula i came up with that will give you cumulative "half-day"units starting at the start date and going up to the right. That made it simple to create a conditional format to highlight those cells which fall within the project length.
=ARRAYFORMULA(IF(B4="",,MMULT(N(VLOOKUP(TEXT(F$2:$2,"dddd"),'day guide'!B$3:D$9,3,0)*(F$2:$2>=B4)),N(F$2:$2>=TRANSPOSE(F$2:$2)))))
I will leave this sheet up indefinitely for others to learn from.

formula in F2:
=INDEX(TRANSPOSE(LEFT(TEXT(ROW(INDIRECT(1*(F1&"1/2021")&":"&
EOMONTH(1*(F1&"1/2021"), ))), {"d", "ddd"}), {2, 1})))
formula in D4:
=QUERY(B4:B, "where B is not null format B 'dddd'")
formmula in E4:
=INDEX(VALUE(F1&"1/2021")-1+TRANSPOSE(QUERY(TRANSPOSE(IFNA(IF(QUERY({
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+0"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+Col2"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+Col2+Col3"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+Col2+Col3+Col4"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+Col2+Col3+Col4+Col5"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+Col2+Col3+Col4+Col5+Col6"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+Col2+Col3+Col4+Col5+Col6+Col7"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:8))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:9))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:10))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:11))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:12))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:13))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:14))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:15))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:16))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:17))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:18))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:19))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:20))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:21))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:22))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:23))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:24))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:25))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:26))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:27))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:28))),
IF(DAY(EOMONTH(F1&"1/2021", 0))>=29,
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:29))),
IFERROR(1/(0^ROW(INDIRECT("3:"&MAX(ROW(A:A)*(A:A<>""))))))),
IF(DAY(EOMONTH(F1&"1/2021", 0))>=30,
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:30))),
IFERROR(1/(0^ROW(INDIRECT("3:"&MAX(ROW(A:A)*(A:A<>""))))))),
IF(DAY(EOMONTH(F1&"1/2021", 0))>=31,
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:31))),
IFERROR(1/(0^ROW(INDIRECT("3:"&MAX(ROW(A:A)*(A:A<>"")))))))},
"offset 1 ", 0)>C4:C,,F2:AJ2))*1),
"select "&TEXTJOIN(",", 1,
"max(Col"&ROW(INDIRECT("4:"&MAX(ROW(A:A)*(A:A<>""))))-ROW(A3)&")"))),, 2)
custom formula for conditional formatting:
=($A4<>"")*(DAY($B4)<=(F$2*1))*(DAY($E4)>=(F$2*1))
spreadsheet demo

I was wondering if you could avoid the use of a heavy array formula in doing this. Yes you can - the conditional format formula is still an array formula, but counts up increasing numbers of values naturally as you move across the range using a fairly simple sumproduct:
=and(F$2>=$B4,SUMPRODUCT(vlookup(text($F$2:F$2,"dddd"),indirect("'day guide'!$B$3:$D$9"),3,false)*($F$2:F$2>=$B4))<=$C4)
My end date formula uses two countifs to total up the whole days and half days but is just a pull-down formula:
=ArrayFormula(min(if((countifs(vlookup(text(F$2:AJ$2,"dddd"),'day guide'!$B$3:$D$9,3,false),1,column(F$2:AJ$2),"<="&column(F$2:AJ$2),F$2:AJ$2,">="&$B4)
+countifs(vlookup(text(F$2:AJ$2,"dddd"),'day guide'!$B$3:$D$9,3,false),2,column(F$2:AJ$2),"<="&column(F$2:AJ$2),F$2:AJ$2,">="&$B4)*2)>=C4,F$2:AJ$2,)))

Related

dartfmt and matrix array

The dart format converts
const ColorFilter greyscale = ColorFilter.matrix(<double>[
0.2126, 0.7152, 0.0722, 0, 0,
0.2126, 0.7152, 0.0722, 0, 0,
0.2126, 0.7152, 0.0722, 0, 0,
0, 0, 0, 1, 0,
]);
to
const ColorFilter greyscale = ColorFilter.matrix(<double>[
0.2126,
0.7152,
0.0722,
0,
0,
0.2126,
0.7152,
0.0722,
0,
0,
0.2126,
0.7152,
0.0722,
0,
0,
0,
0,
0,
1,
0,
]);
and makes it more unreadable, is it possible somehow tell dart formatter that ignore formatting this part of code?

Google Sheets QUERY only takes 3 arguments, but this is argument number 4

=IF(A2 = "", "", QUERY({
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$J$2) - COLUMN(Equipment!$C$2) + 1);
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$F$2) - COLUMN(Equipment!$C$2) + 1);
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$H$2) - COLUMN(Equipment!$C$2) + 1);
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$K$2) - COLUMN(Equipment!$C$2) + 1);
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$O$2) - COLUMN(Equipment!$C$2) + 1);
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$S$2) - COLUMN(Equipment!$C$2) + 1);
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$W$2) - COLUMN(Equipment!$C$2) + 1)
}, "select * where Col1 <> ''"))
, "select * where Col1 <> ''" is underlined red and shows the error: "QUERY only takes 3 arguments, but this is argument number 4."
When I remove the IF part it stops showing the error. Making it all be in one line doesn't help. What am I doing wrong?
EDIT: It seems it may be a visual bug. The query processes correctly, but is still underlined red. The error stopped appearing after I ended up changing it to this:
=QUERY({
IFERROR(INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$J$2) - COLUMN(Equipment!$C$2) + 1), "");
IFERROR(INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$F$2) - COLUMN(Equipment!$C$2) + 1), "");
IFERROR(INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$H$2) - COLUMN(Equipment!$C$2) + 1), "");
IFERROR(INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$K$2) - COLUMN(Equipment!$C$2) + 1), "");
IFERROR(INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$O$2) - COLUMN(Equipment!$C$2) + 1), "");
IFERROR(INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$S$2) - COLUMN(Equipment!$C$2) + 1), "");
IFERROR(INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$W$2) - COLUMN(Equipment!$C$2) + 1), "")
}, "select * where Col1 <> ''")
I don't find any mistake
=IF(A2 = "", "", QUERY({
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$J$2) - COLUMN(Equipment!$C$2) + 1);
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$F$2) - COLUMN(Equipment!$C$2) + 1);
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$H$2) - COLUMN(Equipment!$C$2) + 1);
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$K$2) - COLUMN(Equipment!$C$2) + 1);
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$O$2) - COLUMN(Equipment!$C$2) + 1);
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$S$2) - COLUMN(Equipment!$C$2) + 1);
INDEX(Equipment!$C$2:$X, MATCH(A2, Equipment!$C$2:$C, 0), COLUMN(Equipment!$W$2) - COLUMN(Equipment!$C$2) + 1)
}, "select * where Col1 <> ''"))

How can I make a Google Sheet (or Excel) Gantt chart where some of the weekdays (not necessarily on the weekend) are not full workdays?

I'm trying to make a dally dynamic Gantt chart that takes into account that some of my workdays are not full workdays. For example, if Fridays and Saturdays are both half workdays and Sunday is a non-working day, a three full workdays task that starts on a Monday will be finished on Wednesday. But if the same task starts on a Friday, it will be finished on the consecutive Tuesday. So that the same three full workdays task can fill between three to five days on the Gantt chart.
How can I make this work dynamically on a Google Sheet (or Excel) Gantt chart? Can I make a function that receives the beginning date for a task, takes into accounts all my constraints (for example, Friday is a half-day), and calculates how many days should be filled in the Gantt chart?
Will it be possible to use a higher resolution like a subunit of 1/3 workday?
Attached:
Here is a formula i came up with that will give you cumulative "half-day"units starting at the start date and going up to the right. That made it simple to create a conditional format to highlight those cells which fall within the project length.
=ARRAYFORMULA(IF(B4="",,MMULT(N(VLOOKUP(TEXT(F$2:$2,"dddd"),'day guide'!B$3:D$9,3,0)*(F$2:$2>=B4)),N(F$2:$2>=TRANSPOSE(F$2:$2)))))
I will leave this sheet up indefinitely for others to learn from.
formula in F2:
=INDEX(TRANSPOSE(LEFT(TEXT(ROW(INDIRECT(1*(F1&"1/2021")&":"&
EOMONTH(1*(F1&"1/2021"), ))), {"d", "ddd"}), {2, 1})))
formula in D4:
=QUERY(B4:B, "where B is not null format B 'dddd'")
formmula in E4:
=INDEX(VALUE(F1&"1/2021")-1+TRANSPOSE(QUERY(TRANSPOSE(IFNA(IF(QUERY({
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+0"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+Col2"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+Col2+Col3"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+Col2+Col3+Col4"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+Col2+Col3+Col4+Col5"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+Col2+Col3+Col4+Col5+Col6"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select Col1+Col2+Col3+Col4+Col5+Col6+Col7"),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:8))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:9))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:10))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:11))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:12))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:13))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:14))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:15))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:16))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:17))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:18))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:19))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:20))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:21))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:22))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:23))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:24))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:25))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:26))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:27))),
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:28))),
IF(DAY(EOMONTH(F1&"1/2021", 0))>=29,
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:29))),
IFERROR(1/(0^ROW(INDIRECT("3:"&MAX(ROW(A:A)*(A:A<>""))))))),
IF(DAY(EOMONTH(F1&"1/2021", 0))>=30,
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:30))),
IFERROR(1/(0^ROW(INDIRECT("3:"&MAX(ROW(A:A)*(A:A<>""))))))),
IF(DAY(EOMONTH(F1&"1/2021", 0))>=31,
QUERY(IF(N(IFNA(SPLIT(REPT(10, DAY(INDIRECT("B4:B"&MAX(ROW(B:B)*(B:B<>""))))-1), 0)*
TRANSPOSE(ROW(
INDIRECT("1:"&DAY(EOMONTH(F1&"1/2021", 0))))^0))=0)=0, 0,
TRANSPOSE(QUERY({D12:D18; D12:D18; D12:D18; D12:D18; D12:D18; D12:D18},
"limit "&DAY(EOMONTH(F1&"1/2021", 0))&"
offset "&MATCH(TEXT(F1&"1/2021", "dddd"), C12:C18, 0)-1))),
"select "&TEXTJOIN("+", 1, "Col"&ROW(1:31))),
IFERROR(1/(0^ROW(INDIRECT("3:"&MAX(ROW(A:A)*(A:A<>"")))))))},
"offset 1 ", 0)>C4:C,,F2:AJ2))*1),
"select "&TEXTJOIN(",", 1,
"max(Col"&ROW(INDIRECT("4:"&MAX(ROW(A:A)*(A:A<>""))))-ROW(A3)&")"))),, 2)
custom formula for conditional formatting:
=($A4<>"")*(DAY($B4)<=(F$2*1))*(DAY($E4)>=(F$2*1))
spreadsheet demo
I was wondering if you could avoid the use of a heavy array formula in doing this. Yes you can - the conditional format formula is still an array formula, but counts up increasing numbers of values naturally as you move across the range using a fairly simple sumproduct:
=and(F$2>=$B4,SUMPRODUCT(vlookup(text($F$2:F$2,"dddd"),indirect("'day guide'!$B$3:$D$9"),3,false)*($F$2:F$2>=$B4))<=$C4)
My end date formula uses two countifs to total up the whole days and half days but is just a pull-down formula:
=ArrayFormula(min(if((countifs(vlookup(text(F$2:AJ$2,"dddd"),'day guide'!$B$3:$D$9,3,false),1,column(F$2:AJ$2),"<="&column(F$2:AJ$2),F$2:AJ$2,">="&$B4)
+countifs(vlookup(text(F$2:AJ$2,"dddd"),'day guide'!$B$3:$D$9,3,false),2,column(F$2:AJ$2),"<="&column(F$2:AJ$2),F$2:AJ$2,">="&$B4)*2)>=C4,F$2:AJ$2,)))

How do I make Dartfmt "friendly" for Matrices?

For a Matrix that supposed to look like this:
const ColorFilter sepia = ColorFilter.matrix(<double>[
0.393, 0.769, 0.189, 0, 0,
0.349, 0.686, 0.168, 0, 0,
0.272, 0.534, 0.131, 0, 0,
0, 0, 0, 1, 0,
]);
But dartfmt changed it to become like this:
const ColorFilter sepia = ColorFilter.matrix(<double>[
0.393,
0.769,
0.189,
0,
0,
0.349,
0.686,
0.168,
0,
0,
0.272,
0.534,
0.131,
0,
0,
0,
0,
0,
1,
0,
]);
This is hard to read. Thus, how can I keep the original format so that the Matrix can be seen more "friendly". Or at least how can I make Dartfmt not to reformat any List?
This scenario is described in the FAQ of dart_style which dartfmt is based on:
https://github.com/dart-lang/dart_style/wiki/FAQ#why-does-the-formatter-mess-up-my-collection-literals
In short, you just need to add a comment somewhere in you matrix definition like:
const ColorFilter sepia = ColorFilter.matrix(<double>[
0.393, 0.769, 0.189, 0, 0, //
0.349, 0.686, 0.168, 0, 0,
0.272, 0.534, 0.131, 0, 0,
0, 0, 0, 1, 0,
]);
Then dartfmt will not try to format the newlines in the matrix. It will however, still fixes non-needed spaces so it will make your example into:
const ColorFilter sepia = ColorFilter.matrix(<double>[
0.393, 0.769, 0.189, 0, 0, //
0.349, 0.686, 0.168, 0, 0,
0.272, 0.534, 0.131, 0, 0,
0, 0, 0, 1, 0,
]);
Which can be fixed by changing the 0 to 0.000:
const ColorFilter sepia = ColorFilter.matrix(<double>[
0.393, 0.769, 0.189, 0, 0, //
0.349, 0.686, 0.168, 0, 0,
0.272, 0.534, 0.131, 0, 0,
0.000, 0.000, 0.000, 1, 0,
]);
Whereas #julemand101's answer should be the accepted one, as it directly changes dartfmt's behavior, this spread operator workaround could be worth to mention :
final matrix = [
...[1, 2, 3],
...[4, 5, 6],
...[7, 8, 9],
];

KNN find nearest error

I'm doing KNN classification of static gestures and i get this error.
ERROR: Unhandled exception at 0x01213aa2 in NUIGHR.exe: 0xC0000005:
Access violation reading location 0x00000000.
CvMat* GetFeatures(CvSeq* contour, CvSeq* hull, double boundingRectArea){
CvMoments moments;
CvHuMoments humoments;
cvMoments(contour, &moments, cvGetHuMoments(&moments, &humoments);
int cCont;
double cArea, cPerimeter, cDiameter, cExtent, cCompactness, cEccentricity, cCircularity;
cCont = contour->total;
cArea = fabs(cvContourArea(contour));
cPerimeter = cvContourPerimeter(contour);
cDiameter = sqrt( 4 * cArea / CV_PI);
cExtent = cArea / (boundingRectArea * boundingRectArea);
cCompactness = (4 * cArea * CV_PI) / cPerimeter;
cEccentricity = pow( (moments.m20 - moments.m02), 2) - (4 * pow(moments.m11, 2)) / ( pow(moments.m20 + moments.m02, 2) );
cCircularity = pow(cPerimeter, 2) / cArea;
cvmSet( featureVector, 0, 0, boundingRectArea);
cvmSet( featureVector, 0, 1, cCont);
cvmSet( featureVector, 0, 2, cArea);
cvmSet( featureVector, 0, 3, cPerimeter);
cvmSet( featureVector, 0, 4, cDiameter);
cvmSet( featureVector, 0, 5, cExtent);
cvmSet( featureVector, 0, 6, cCompactness);
cvmSet( featureVector, 0, 7, cEccentricity);
cvmSet( featureVector, 0, 8, cCircularity);
cvmSet( featureVector, 0, 9, humoments.hu1);
cvmSet( featureVector, 0, 10, humoments.hu2);
cvmSet( featureVector, 0, 11, humoments.hu3);
cvmSet( featureVector, 0, 12, humoments.hu4);
cvmSet( featureVector, 0, 13, humoments.hu5);
cvmSet( featureVector, 0, 14, humoments.hu6);
cvmSet( featureVector, 0, 15, humoments.hu7);
return featureVector;
}
int main(){
...
const int K = 10;
CvKNearest *knn = NULL;
float resultNode = 0;
CvMat* featVector = cvCreateMat(1, NUMBER_OF_FEATURES, CV_32FC1 );
CvMat* nearest = cvCreateMat(1, K, CV_32FC1);
...
resultNode = knn->find_nearest(&featVector, K, 0, 0, nearest, 0);
}
I think i need to convert CvMat* to CvMat.
How do i do it?
You cannot pass 0 as 3rd and 4th argument to find_nearest function, not if you do pass something as 5th argument. OpenCV tries to populate the results and neighbourResponses (see doc), but cannot read/write the NULL pointer.
featureVector = NULL pointer
sorry guys... i'm a beginner :(

Resources