SOLVED: Group By & Ordering

dimoss

Well-Known Member
Hi,

I am searching for a way to get a proper ordering of grouped by fields based on existing field.
I found the following:

https://forum.fabrikar.com/forums/index.php?threads/order-by-sum.49189/#post-257128

It is mentioned that ordering is available for single fields.

In my list there is a field called 'Total' which holds the sum of values per record which is actually the sum of other elements in the same list. Let's say my list is composed by 'Name', 'field1', 'field2', 'field3' 'Total' (where total is the sum of fields 1,2,3). The ordering works fine if apply it on the 'Total' without applying any Group By.
However when I group by 'Name' to present the name with the highest accumulated 'Total' it doesnt work properly.
I don't know if i am doing something wrong or it doesnt work like that or I should prepare another view but any help is appreciated.
 
upload_2023-9-14_19-14-25.png
Did you set 'Total' in the "Order by" of the "Group by" options?

But seems still issue

test.jpg

5414dd_2kw
 
Last edited:
Not sure what this is showing.
In your other thread these "label:: value" were element list calculations.
What is this here? Normal elements? With format strings?
 
upload_2023-9-14_19-48-9.png


This Order by refers to the internal order inside each group.

However as per the image in my previous post, I want all the grouped by sets to be orders by Total.
 
Not sure what this is showing.
In your other thread these "label:: value" were element list calculations.
What is this here? Normal elements? With format strings?

All the elements in the screen above are normal fields elements (INT). The last element 'Total' is the sum of the columns 'MS','WS','MD','WD',XD which contain amounts (INT).

Does the grouped by calculates the sum of Totals for each 'Name' and make the order by?

When I select to group by Name i expect to get the grouped sets ordered by Total.
 
Unless you refer to this calculation and the grouped by sets cannot be ordered in calculations on the fly and I need to preare another view using a custom MySQL query.

upload_2023-9-14_19-59-59.png
 
I'm a bit confused.
You can only order by elements in a single, normal row not by "sums" in the "Calculation" row which may be displayed below each group if the list is "Grouped by".
Order by is using the element's value is stored in the database (so - like filters - it won't do if you have a calc element which is calculating the list display value "on the fly" showing a value different from the one in the DB)

Yes, maybe a list linked to a MySQL view can do what you want.
 
I'm a bit confused.
You can only order by elements in a single, normal row not by "sums" in the "Calculation" row which may be displayed below each group if the list is "Grouped by".
Order by is using the element's value is stored in the database (so - like filters - it won't do if you have a calc element which is calculating the list display value "on the fly" showing a value different from the one in the DB)

Yes, maybe a list linked to a MySQL view can do what you want.
This is what I thought and doesn't sort sum calculations on the fly but only values in the DB field.
I will create a MySQL view and then a list connected to it and i will solve it :)
Thanks @troester
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top