Sheets formula for summing values with same name - google-sheets

I am trying to sum values for individual people who have multiple rows in one column and values (prices) in another. I am trying to have a column for the summed values for each person. Right now I am using =sum for each individual person but am looking for a way to code/use a formula to streamline the process.

use:
=QUERY(A:B; "select A,sum(B) where A is not null group by A label sum(B)''")

Related

How to text wrap some cells in a google sheet column?

I have a google sheet, wherein the first two columns are filled using "Arrayformula" from a pivot table. Is it possible to merge some of the cells in first column while using Arrayformula.
Below is an image of sample data which I am obtaining from the pivot. I would like to have "Porsche" from 1st column to be text wrapped for all its corresponding customer IDs.
https://i.stack.imgur.com/Pdt4I.png
Thank you
You can try using query to filter out rows where there are no Customer IDs.
Formula:
=arrayformula(query({A1:B}, "where Col2 is not null"))
Output:
If this isn't the one you want, kindly provide your expected result as I'm unsure with how you used the term "text wrapped"

How can I separate a column into multiple columns based on values?

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")})

Google Sheets Combine a column with duplicates and update total sum in another colum

This might be something fairly simple but struggling to find a way to do it.
In Column B, I have a list of foods required.
In Column C, I have the amount needed.
In Column D, I have g (for grams) ml (for mills) etc.
I would like to combine the duplicates in Column B and update the totals from Column C, with the g or ml in Column D beside it.
The list I have has been created by using an array formula based on dropdowns in another sheet.
I have seen people using UNIQUE formula in 1 column (this works) and then a SUMIF formula in another column and then a JOIN formula in another... I tried this but the SUMIF is always returning 0.
Would someone please be able to advise on how I can do this?
TIA :D
It's hard to be sure exactly what you need without seeing the data. But based on my understanding of solely what you've posted, this QUERY formula should generate a condensed mini-report:
=QUERY({B2:D},"Select Col1, SUM(Col2), Col3 WHERE Col1 Is Not Null GROUP BY Col1, Col3 LABEL SUM(Col2) ''")
In plain English, this means "Arrange the data from the range B2:D in the same order as the raw data, but sum the second column's data according to matches in both the first and third columns. Only return results for the raw data where the first column is not blank. Replace the default 'sum' header on the second column with nothing; I don't need it."
This formula assumes that every ingredient will always be attached to the same measurement (e.g., 'salt' in Col B is always paired with 'mg' in Col D, etc.). If this is not the case, you will wind up with ingredients being listed as many times as there are different measures in Col D.

In Google Sheets, how to query and sum all values which have the same description?

I am using a query formula to import data from a different sheet.
However after querying the data, I got the same code which I need to sum the episode and the value with unique formula therefore after querying only show unique code. I'm not sure how to mix the formula.
My query formula is the following:
=QUERY(Paste!A:M,"SELECT A,B,C ORDER BY C DESC LIMIT 15")
My spreadsheet link is the following:
https://docs.google.com/spreadsheets/d/1A6lGIlU147Y_0WFD7Btkq4IMuY-Z3D1HsNiTgjLjm0o/edit?usp=sharing
As above image. Under column A I have same code for FMEM1 due to my raw data separate it for some reason. I don't want the same code separated. I want unique code not separated and sum the episode and sum the value
try
=query({A3:A17,B3:B17,C3:C17},"select Col1, Sum(Col2),Sum(Col3) group by Col1 label Col1 'Code',Sum(Col2) 'Total Episode',Sum(Col3) 'Total Value'")
Screenshot

Pivot table with double rows or going from wide to long in Google Sheets

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)))

Resources