I have multiple spreadsheets from which I am importing multiple sheets and then stacking the data vertically. The obstacle I am trying to move past is that every spreadsheet is a different company's information and when I query that information from another sheet that I made I am unable to differentiate the various sources of data from one another. Certainly, I could simply add a column to all of the original spreadsheets with the name of the company and include that in my query formulas, but I would rather use something more dynamic. Alternatively, maybe there is a way to ask a cell where it's value came from.
An example would be:
A2 = "San Diego" B2 = "$2.24" C2 = "Company 1"
A3 = "San Francisco" B3 = "$1.89" C3 = "Company 2"
A4 = "Indianapolis" B4 = "$4.21" C4 = "Company 2"
try something like:
=QUERY(QUERY(IMPORTRANGE("ID", "Sheet1!A:B"), "select Col1,Col2,'Company 1'", 0), "offset 1", 0)
then you could do array like:
={QUERY(QUERY(IMPORTRANGE("ID", "Sheet1!A:B"), "select Col1,Col2,'Company 1'", 0), "offset 1", 0);
QUERY(QUERY(IMPORTRANGE("ID", "Sheet5!C:D"), "select Col1,Col2,'Company 3'", 0), "offset 1", 0)}