I’m dealing with a Google Sheets formula that employs QUERY alongside LAMBDA and INDEX functions. The main issue is that numeric values processed by my query stop functioning correctly for calculations. I constructed this formula by merging different functions to extract data from my primary sheet.
Here’s my current formula:
=FILTER(MAP(x, y, {y; IFERROR(VLOOKUP(y, x, ROW(INDIRECT("1:" & ROWS(QUERY(x, "limit 1", )))), ))}) (QUERY(DATA!A1:K, "select A, sum(G), H where C = 'abc123-def4-5678-ghij-klmnopqrstuvw' and I = 'Main' group by A, H pivot D", 1), {"Record Id", IFERROR(LOOKUP(ROW(INDIRECT("1:9")), {CONFIG!C2:C, CONFIG!F2:F }, 2, )), "Document Id"}))
The issue I’m facing:
When I try to copy numeric values from the query results into other cells for mathematical operations, they appear as 0 instead of showing the correct calculated numbers. Text values copy without a problem, and boolean and date values can be processed through functions. However, straightforward copying of numbers fails.
Here’s what works:
- String values copy successfully.
- Boolean values function with IF statements.
- Date values work adequately with date functions.
- When I use a formula reference (such as multiplying by 2), the numbers function correctly.
Here’s what doesn’t work:
- Directly copying number values for addition.
- Basic sum formulas that utilize the query results fail to compute correctly.
I believe this issue arises because the QUERY function determines the data type based on the most common format found in the source data. Since my data contains a mix of formats (numbers, text, dates, booleans) within the same column structure, it complicates things.
Is there a way to adjust my query formula to ensure that numbers remain as numbers even after being copied? The solution should still function appropriately even if other data formats are more prevalent than numbers in my original data.