0

I have a table

Name Salary Desc2 Desc3
ABC 9 X X
ABC 9 X X
ABC 9 X X
XYZ 4 Y Y
PQR 1 Z Z
PQR 1 Z Z
PQR 1 Z Z

I want it something like :-

Name Salary Desc2 Desc3
ABC 27 X X
XYZ 4 Y Y
PQR 3 Z Z

2 Answers 2

2

Very simple:

=Query({A1:D8}, "select Col1, sum(Col2), max(Col3), max(Col4) group by Col1",1)
2
  • Could you explain why the use of max() ??
    – Daniele
    Commented Oct 30, 2022 at 6:21
  • min and max are your only two options for collapsing text, it basically just selects alphabetically in case there is variance in that column.
    – CodeCamper
    Commented Oct 30, 2022 at 6:26
2

Assuming that the columns to be considered are those from A to D and that row 1 is reserved for headings, you could try this formula:

=query(A1:D,"select A,sum(B),C,D where A is not null group by A,C,D ",1)
1
  • I like to always wrap references in {} in a query so I can use the Col1 format because if you move a single column it messes up your entire string.
    – CodeCamper
    Commented Oct 30, 2022 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.