I have lots of sheets describing different kind of expenses and gains of my small company, and I find no easy way to merge my tables like in this example I made:
I want the last table to be auto filled with the lines of the others tables when I update them, so I can foresee the expenses and gain in time (by ordering the green table automatically by date ascending).
By now the only temp solution I found is to copy references to the other tables lines (yellow and blue) in the merging table (green) in advance.
Pivot tables do not permit to achieve this kind of gathering on several tables.
Use this Query formula in cell I2:
=QUERY({A2:C; E2:G}, "select * where Col1 is not null", 1)
To also order them by Date, add the order by:
=QUERY({A2:C; E2:G}, "select * where Col1 is not null order by Col1", 1)
Related
I have two columns of text/abbreviations i want to summarize in a (or two respectively) tables.
Example:
Column 1: SiteScopeInput
Swap_G09+Remove_U21+Rollout_L07+Swap_L08+Swap_L18+Rollout_L21+Rollout_N35
Remove_U21+Rollout_L07+Swap_L08+Swap_L18+Rollout_L21+Rollout_N35
Swap_G09+Rollout_L07+Swap_L08+Swap_L09+Swap_L18+Rollout_L21+Swap_L26+Rollout_N35
Swap_G09+Remove_U21+Rollout_L07+Swap_L08+Swap_L18+Rollout_L21+Rollout_N35
Here I'd like to summarize how many times words occure - for example:
Swap_G09
Remove_U1
Rollout_L07
and so on.
I've tried a combination of
ArrayFormula, LEN and REGEXREPLACE
but my beginner mind can't wrap around this task.
Any tips? Thanks!
If you want to treat Swap_G09 etc. as a separate word, then a combination of split, flatten and query should do it:
=ArrayFormula(query(FLATTEN(split(filter(A:A,A:A<>""),"+")),"select Col1,count(Col1) where Col1 is not null group by Col1 label Col1 'Word'"))
I have searched on a lot of pages but I cannot find a solution to my problem except in reverse order. I have simplified what I do, but I have a query that comes looking for information in my data sheet. Here there are 3 columns, the date, the amount and the source.
I would like, with a query function, to be able to make different columns which counts the information of column C based on the values of its cells per month, like this
I'm okay with the start of the formula
=QUERY(A2:C,"select month(A)+1, sum(B), count(C) where A is not null group by month(A)+1")
But as soon as I try a little different things by putting 2 query together in an arrayformula, obviously the row count doesn't match as some minus are 0 for some sources.
Do you have a solution for what I'm trying to do? Thank you in advance :)
Solution:
It's not possible in Google Query Language to have a single query statement that has one result grouped by one column and another result grouped by another.
The first two columns can be like this:
=QUERY(A2:C,"select month(A)+1, sum(B) where A is not null group by month(A)+1 label month(A)+1 'Month', sum(B) 'Amount'")
To create the column labels for the succeeding columns, use in the first row, in my example, I1:
=TRANSPOSE(UNIQUE(C2:C))
Then from cell I2, enter this:
=COUNTIFS(arrayformula(month($A$2:$A)),$G2,$C$2:$C,I$1)
Then drag horizontally and vertically to apply to the entire table.
Results:
try:
=INDEX({
QUERY({MONTH(A2:A), B2:C},
"select Col1,sum(Col2) where Col2 is not null group by Col1 label Col1'month',sum(Col2)'amount'"),
QUERY({MONTH(A2:A), B2:C, C2:C},
"select count(Col3) where Col2 is not null group by Col1 pivot Col4")})
I have a spreadsheet containing different classes that students are scheduled into. Is there a way to consolidate all the values into one row for each student and sort the classes into their respective columns? The first two rows are what I would like the sheet to look like. One row for each student and the course columns sorted by subject.
try:
=QUERY({A2:D, D2:D},
"select Col1,Col2,max(Col4)
where Col1 is not null
group by Col1,Col2
pivot Col5")
I'm using an array to bring 2 columns of data together from 3 sheets.
There are duplicates in the second column, and I would like to group those duplicates together and display both Col1 and Col2, ordered alphabetically by Col1.
This is the formula I have right now:
=QUERY({'Sheet1!'A:B;'Sheet2!'A:B;'Sheet3!'A:B}, "Select Col1, count(Col2) where Col1 is not null group by Col1",1)
Which only displays Col1.
I've tried nesting QUERY, but I can't get it to work and can't find any direction anywhere online.
Here's an example sheet I made to show what I'm trying to do:
https://docs.google.com/spreadsheets/d/1_x0mXZC0ZjsHDCd6I0dDf9OI19lrzEcPYqfcMxuK74Y/edit?usp=sharing
In the example if an employee is listed twice the name may change but the email is consistent. I'm hoping to group by the email addresses and return only one name (it doesn't really matter which name).
I'm not sure if this is possible without formulas in more than one cell. Thank you either way!
#confuseddesk, try this array formula:
=ArrayFormula(QUERY({VLOOKUP(UNIQUE({Sheet2!B2:B;Sheet3!B2:B;Sheet4!B2:B}),{Sheet2!B2:B,Sheet2!A2:A;Sheet3!B2:B,Sheet3!A2:A;Sheet4!B2:B,Sheet4!A2:A},2,FALSE),UNIQUE({Sheet2!B2:B;Sheet3!B2:B;Sheet4!B2:B})},"Select * Where Col2 Is Not Null"))
How can I go from wide to long in Google Sheets based on two different columns or create a pivot table where I specify two different columns from the original matrix as rows?
Please see example for intended effect:
you can do it like this all in one go:
=ARRAYFORMULA(QUERY({
A1:B, TEXT(C1:C, "hh:mm");
A2:A, D2:D, TEXT(C2:C, "hh:mm")},
"select Col2,max(Col1)
where Col2 is not null
group by Col2
pivot Col3", 1))
Here's a fairly simple approach. I don't think you can use a pivot table because the values have to be summaries of a numeric value, or at least counts, not a string value.
To get the times:
=transpose(C2:C)
To get the lecturers (fairly big assumption that there are no lecturers that work only as assistants but this can be changed later):
=unique(B:B)
If there are additional lecturers working only as assistants:
=unique({B:B;D2:D})
Then to get the topic corresponding to a particular lecturer or assistant:
=ArrayFormula(IFERROR(vlookup(filter(F2:F,F2:F<>"")&filter(G1:1,G1:1<>""),{B2:B&C2:C,A2:A},2,false))&
IFERROR(vlookup(filter(F2:F,F2:F<>"")&filter(G1:1,G1:1<>""),{D2:D&C2:C,A2:A},2,false)))