Calc: Sorting by Multiple Rows/Criteria

Hello,

I have the following table:

Name	Value
A	34
B	53
C	13
D	1
D	45
D	90
A	54
C	3
A	77
A	43

That I would like to convert into:

Name	Value
A	34
A	43
A	54
A	77
D	1
D	45
D	90
B	53
C	3
C	13

As you can see the aim is to first sum the values for each name, and then sort the names based on their summed value. So in this case the total value of all A’s is 208 which is the biggest value so I want the A’s to be first, D’s are second so I want them second, the only B has a total value greater than all C’s so it’s above the C’s.

I still want to keep each row though as it’s important for me to see each individual value.

Is something like that possible?

Hi @oliko, I think the proper tool in calc is the Pivot Table Menu/Data/Pivot Table.

Open the attached file to see a sample: Sum&Sort.png (please change the extension to .ods, here is a issue to upload files with odf extensions)

The trick is set up the Name to be sorted by their sum.

Edited:

Another way to do it: Add a third column with the sum for every value, what you can use to sort, (Menu/Data/Sort).

image description

Thank you - this works very well! Not the most elegant solution - since I can’t tweak the values in the cells - it’s more of a display solution, but nonetheless - a solution! I reckon if I copy/paste the output back into a sheet I’ll get a normal table that I can work with and it will also be sorted! So thank you once more - you truly saved the day!

Where you can tweak the values is in the source table, right-click in Pivot Table and Refresh.

RE: Your EDIT - using SUMIF!

Now that is an ELEGANT SOLUTION!

I was struggling to come up with something like this, but I never thought of something as simple and elegant as this!

Thank you once again - words cannot express my smile right now! :slight_smile: