I'm trying to display sample data as follows. I'm able to do this using pivot tables and multiple values with no problem but would like to find a way using either Query or some other method. This problem was partly solved using the formula below but does not include the 'Other' column.
=Index({"",Transpose(Unique(Filter(B2:B,B2:B<>"")));Flatten({Sort(Unique(C2:C)),IFError(Unique(C2:C)/0)}),IFNA(VLookup(Transpose(Unique(Filter(B2:B,B2:B<>"")))&Flatten({Text(Sort(Unique(C2:C)),"hh:mm"),Text(Sort(Unique(C2:C)),"hh:mm")&".1"}),{Flatten({B2:B&Text(C2:C,"hh:mm"),B2:B&Text(C2:C,"hh:mm")&".1"}),Flatten({A2:A,D2:D})},2,0))})
Sample data:
Desired result:
use:
=ARRAYFORMULA({"", TRANSPOSE(UNIQUE(FILTER(B2:B, B2:B<>"")));
FLATTEN({SORT(UNIQUE(C2:C)), IFERROR(TEXT(UNIQUE(C2:C), {"#", "#"})/0)}),
IFNA(VLOOKUP(TRANSPOSE(UNIQUE(FILTER(B2:B, B2:B<>"")))&FLATTEN({TEXT(SORT(UNIQUE(C2:C)), "hh:mm"),
TEXT(SORT(Unique(C2:C)), "hh:mm")&{".1", ".2"}}), {FLATTEN({B2:B&TEXT(C2:C, "hh:mm"),
B2:B&TEXT(C2:C, "hh:mm")&{".1", ".2"}}), FLATTEN({A2:A, D2:D, E2:E})}, 2, ))})
Related
Good Morning,
Right now we have a field where we are using =vlookup to find data matching certain identifiers.This data come from sheet "Raw Data" and is filtered into "Data".
Now what I want to do is be able to fill in extra data in B2:F5 in columns which are empty without the formula breaking / being removed or getting an #REF.
The vlookup I am using right now
=arrayformula(transpose(VLOOKUP(A2;'Raw Data'!A2:F5;{2;3;4})))
Example file: https://docs.google.com/spreadsheets/d/17M5muIZA2nUgjRTj_OHlW9Fw6IECEFWuYuYmgFh3lEM/edit#gid=0
use:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A; 'Raw Data'!A2:F; {2\ 3\ 4\ 5\ 6}; 0)))
I currently have 6 columns that are populating from another sheet with the query formula, based on column name. I would like to combine these 6 columns into one column, eliminating duplicates, and listing them all in one-singular column. I've tried the following without success:
FILTER(UNIQUE(A2:A, B2:B, C2:C, D2:D, etc.),ISBLANK({same list})=FALSE))
FLATTEN(TRANSPOSE(A2:A, B2:B, C2:C, etc.))
FILTER(UNIQUE({A2:A,B2:B;C2:C; etc.}), LEN(UNIQUE({A2:A,B2:B;C2:C; etc.})))
The catch seems to be that sometimes the columns will be blank. I think google sheets is either reading them as blank and giving me an error, or sees there a query'd set of data and it's unable to retrieve the list.
Any recommendations?
This should work, if I'm understanding you correctly:
=QUERY(FLATTEN(A2:F),"WHERE Col1 Is Not Null")
I am trying to use a Query to replicate the behaviour pictured below. I have a pivot table with two values (as rows) displaying a job name and it's status. This works fine with the built-in pivot table.
Sample Data:
Resulting pivot table:
I've then tried to recreate this using the following Query formula:
=QUERY(A1:D6, " select C, max(A), max(D) GROUP BY C PIVOT B Order by C ")
This gives me the result below. This is as close as I've managed to get to replicating the original pivot table.
Edit
The main part of this question has been solved below but I'm wondering how to extend this out if I had more columns of data that I then wanted to display in the same way. Below I have added an additional column 'Other'.
New data:
New desired result:
Try:
=Index({"",Transpose(Unique(Filter(B2:B,B2:B<>"")));Flatten({Sort(Unique(C2:C)),IFError(Unique(C2:C)/0)}),IFNA(VLookup(Transpose(Unique(Filter(B2:B,B2:B<>"")))&Flatten({Text(Sort(Unique(C2:C)),"hh:mm"),Text(Sort(Unique(C2:C)),"hh:mm")&".1"}),{Flatten({B2:B&Text(C2:C,"hh:mm"),B2:B&Text(C2:C,"hh:mm")&".1"}),Flatten({A2:A,D2:D})},2,0))})
Ive got 4 columns that i want to summerise as part of a calculated field in a pivot table.
In Sheet 1 i have the raw data and in Sheet 2 i have the pivot table.
For the calculated field i want to sum the values for the following columns named "Alpha", "Beta", "Charlie", "Delta". In this example the columns are L,M,N,Z.
To generate this calcualted feild value do this ive been trying the following ="Alpha"+"Beta"+"Charlie"+"Delta" and also =L+M+N+Z.
But they both through errors.
Im sure its something wrong with my syntax, but cant work out what.
Any ideas ?
This also worked for me:
=sum('Alpha', 'Beta', 'Charlie', 'Delta')
Good luck :)
You need to reference your columns with single-quote:
='Alpha'+'Beta'+'Charlie'+'Delta'
Google sheet pivot only allows column name from the source data to be used as reference in the calculated field or a direct cell reference, e.g. A1.
I believe in my testing it would be:
=sum(L,M,N,Z)
From this post, you can also use ArrayFormula. So you can do this simply:
=ArrayFormula(Alpha+Beta+Charlie+Delta)
I would like to aggregate the data of multiple spreadsheets into one spreadsheet.
Spreadsheet 1 has a Row of Strings A2:A500
Spreadsheet 2 has a Row of Strings A2:A500
Spreadsheet 3 is supposed to have a Row of both (Spreadsheet1!A2:A500 AND Spreadsheet2!A2:A500).
Duplicates shall not be handled differently. I would like them to appear as often as they appear in the different sheets.
Is it possible to do this without writing a script or using jQuery, e.g. by using IMPORTRANGE?
What does not work: I have tried using IMPORTRANGE as follows:
ARRAY{IMPORTRANGE("key-of-spreadsheet1","list!A2:A500"), IMPORTRANGE("key-of-spreadsheet2", "list!A2:A500")}
This causes an error.
You should be able to use a vertical array in the Spreadsheet 3:
={IMPORTRANGE("Sheet1Key","SheetName!A2:A500");IMPORTRANGE("Sheet2Key","SheetName!A2:A500")}
Of course, it is also possible to combine several IMPORTRANGE() functions with the QUERY() function, which gives us a greater control over the results we import.
For example, we can use such a construction:
=QUERY(
{
IMPORTRANGE("key-or-url-of-spreadsheet-1", "'sheet-name-1'!A2:Z100");
IMPORTRANGE("key-or-url-of-spreadsheet-2", "'sheet-name-2'!A2:Z100");
IMPORTRANGE("key-or-url-of-spreadsheet-3", "'sheet-name-3'!A2:Z100");
IMPORTRANGE("key-or-url-of-spreadsheet-4", "'sheet-name-4'!A2:Z100")
},
"SELECT * WHERE Col1 IS NOT NULL ORDER BY Col3 ASC"
)
###Explanation:
The above query removes blank lines from imported ranges:
SELECT * WHERE Col1 IS NOT NULL
and sorts ascending all data collected together in relation to the third column:
ORDER BY Col3 ASC
For descending, just use DESC in place of ASC.
Of course, we can also arrange any other criteria, or omit them displaying everything without modification:
"SELECT * "
###Note:
In order to use the above constructed query, we first need to call a single IMPORTRANGE() method for each of the spreadsheets we want to refer:
=IMPORTRANGE("key-or-url-of-spreadsheet-1", "'sheet-name-1'!A2:Z100")
We have to do this even if we refer to the same spreadsheet in which we write this formula, but for every spreadsheet it is enough to do it once.
This is to be able to connect these sheets and allow access to the sheets (to which we have the access rights anyway):
After giving permission for all spreadsheets, we can use the above query.
I am also applying above given formula for getting data from multiple spreadsheet which is getting an error something is like IN ARRAY_LITERAL An array literal was missing values for one or more rows.
Easy fix: Apply the filter to the entire column / sheet instead of just the current selection. This will automatically update all of the filters to include new additions.