- wrap it in
IFERROR
and add fake columns for false part
IFERROR(your-query-here; {""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""})
full formula in ZDP08!A2 cell:
={
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!A4;"dd/mm/yyyy")&"', H*"&substitute('Input Longo'!A5;","; ".")&"
WHERE H IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!A4;"dd/mm/yyyy")&"' '', H*"&substitute('Input Longo'!A5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!B4;"dd/mm/yyyy")&"', H*"&substitute('Input Longo'!B5;","; ".")&"
WHERE H IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!B4;"dd/mm/yyyy")&"' '', H*"&substitute('Input Longo'!B5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!C4;"dd/mm/yyyy")&"', I*"&substitute('Input Longo'!C5;","; ".")&"
WHERE I IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!C4;"dd/mm/yyyy")&"' '', I*"&substitute('Input Longo'!C5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!D4;"dd/mm/yyyy")&"', I*"&substitute('Input Longo'!D5;","; ".")&"
WHERE I IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!D4;"dd/mm/yyyy")&"' '', I*"&substitute('Input Longo'!D5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!E4;"dd/mm/yyyy")&"', J*"&substitute('Input Longo'!E5;","; ".")&"
WHERE J IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!E4;"dd/mm/yyyy")&"' '', J*"&substitute('Input Longo'!E5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!F4;"dd/mm/yyyy")&"', J*"&substitute('Input Longo'!F5;","; ".")&"
WHERE J IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!F4;"dd/mm/yyyy")&"' '', J*"&substitute('Input Longo'!F5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!G4;"dd/mm/yyyy")&"', K*"&substitute('Input Longo'!G5;","; ".")&"
WHERE K IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!G4;"dd/mm/yyyy")&"' '', K*"&substitute('Input Longo'!G5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!H4;"dd/mm/yyyy")&"', K*"&substitute('Input Longo'!H5;","; ".")&"
WHERE K IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!H4;"dd/mm/yyyy")&"' '', K*"&substitute('Input Longo'!H5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!I4;"dd/mm/yyyy")&"', L*"&substitute('Input Longo'!I5;","; ".")&"
WHERE L IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!I4;"dd/mm/yyyy")&"' '', L*"&substitute('Input Longo'!I5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!J4;"dd/mm/yyyy")&"', L*"&substitute('Input Longo'!J5;","; ".")&"
WHERE L IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!J4;"dd/mm/yyyy")&"' '', L*"&substitute('Input Longo'!J5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!K4;"dd/mm/yyyy")&"', M*"&substitute('Input Longo'!K5;","; ".")&"
WHERE M IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!K4;"dd/mm/yyyy")&"' '', M*"&substitute('Input Longo'!K5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!L4;"dd/mm/yyyy")&"', M*"&substitute('Input Longo'!L5;","; ".")&"
WHERE M IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!L4;"dd/mm/yyyy")&"' '', M*"&substitute('Input Longo'!L5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!M4;"dd/mm/yyyy")&"', N*"&substitute('Input Longo'!M5;","; ".")&"
WHERE N IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!M4;"dd/mm/yyyy")&"' '', N*"&substitute('Input Longo'!M5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!N4;"dd/mm/yyyy")&"', N*"&substitute('Input Longo'!N5;","; ".")&"
WHERE N IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!N4;"dd/mm/yyyy")&"' '', N*"&substitute('Input Longo'!N5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!O4;"dd/mm/yyyy")&"', O*"&substitute('Input Longo'!O5;","; ".")&"
WHERE O IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!O4;"dd/mm/yyyy")&"' '', O*"&substitute('Input Longo'!O5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!P4;"dd/mm/yyyy")&"', O*"&substitute('Input Longo'!P5;","; ".")&"
WHERE O IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!P4;"dd/mm/yyyy")&"' '', O*"&substitute('Input Longo'!P5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!Q4;"dd/mm/yyyy")&"', P*"&substitute('Input Longo'!Q5;","; ".")&"
WHERE P IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!Q4;"dd/mm/yyyy")&"' '', P*"&substitute('Input Longo'!Q5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!R4;"dd/mm/yyyy")&"', P*"&substitute('Input Longo'!R5;","; ".")&"
WHERE P IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!R4;"dd/mm/yyyy")&"' '', P*"&substitute('Input Longo'!R5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!S4;"dd/mm/yyyy")&"', Q*"&substitute('Input Longo'!S5;","; ".")&"
WHERE Q IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!S4;"dd/mm/yyyy")&"' '', Q*"&substitute('Input Longo'!S5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!T4;"dd/mm/yyyy")&"', Q*"&substitute('Input Longo'!T5;","; ".")&"
WHERE Q IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!T4;"dd/mm/yyyy")&"' '', Q*"&substitute('Input Longo'!T5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!U4;"dd/mm/yyyy")&"', R*"&substitute('Input Longo'!U5;","; ".")&"
WHERE R IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!U4;"dd/mm/yyyy")&"' '', R*"&substitute('Input Longo'!U5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!V4;"dd/mm/yyyy")&"', R*"&substitute('Input Longo'!V5;","; ".")&"
WHERE R IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!V4;"dd/mm/yyyy")&"' '', R*"&substitute('Input Longo'!V5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!W4;"dd/mm/yyyy")&"', S*"&substitute('Input Longo'!W5;","; ".")&"
WHERE S IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!W4;"dd/mm/yyyy")&"' '', S*"&substitute('Input Longo'!W5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""});
IFERROR(QUERY('Input Longo'!A8:S;"SELECT '000', A, B, C, D, E, ' ', F, ' ', ' ', ' ', G, ' ', ' ', ' ', '"&TEXT('Input Longo'!X4;"dd/mm/yyyy")&"', S*"&substitute('Input Longo'!X5;","; ".")&"
WHERE S IS NOT NULL
LABEL '000' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', ' ' '', '"&TEXT('Input Longo'!X4;"dd/mm/yyyy")&"' '', S*"&substitute('Input Longo'!X5; ","; ".")&" ''");{""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""\""})}
Best Answer
In your sample data, the first and last values are also the smallest and largest per name. If that is the case with your real data as well, you can get those values like this:
=query(A1:C, "select A, min(B), max(B) where A is not null group by A", 1)
In your sample spreadsheet, the first and last values are also the earliest and latest by the date in column
C
. These formulas will give results that match the expected results you show:=query(A1:C, "select A, toDate(min(C)), toDate(max(C)) where A is not null group by A", 0)
=arrayformula( if( isnumber(K3:K) * (K3:K = J3:J), 0, iferror( vlookup($I3:$I & J3:J, { $A1:$A & int($C1:$C), $B1:$B }, 2, false) ) ) )
=arrayformula( iferror( vlookup($I3:$I & K3:K, { $A1:$A & int($C1:$C), $B1:$B }, 2, false) ) )
=arrayformula( if( M3:M + L3:L, M3:M - L3:L, iferror(1/0) ) )