I have an aggregated view created with the views_aggregator contrib module, which has an average column. I would like to order the view by this aggregated value. Is that possible? Right now, it doesn't seem to work. This NOTA column is an aggregated value and is the field used in the sort section of the view, but it is not sorted:
Comments
Aha, although it gets ordered when using the configurations of the view format.
wow, the order set in the view's format settings only works with php 8.1+, not with php 7.4....
Hi Robert. I'm looking at D7 issues about this - apparently this is possible since 10 years ago, which means the functionality is there, but there may be some issues with the way your view is configured. Could you take a picture of the Settings UI within the Format option of Views? Id like to see how you are grouping and compressing by club and then calculating the average to the other column (both in "group aggregation").
Hmm... I was able to reproduce this issue when I thought it would work. Wuold you mind opening an issue in the queue?
BTW, this is still a problem in the D7 version (despite what that issue said), so I'm not sure this is possible. I'll have to look more closely into it.
Issue opened.
Just posting the issue link here for the record
https://github.com/backdrop-contrib/views_aggregator/issues/28
I'm reposting AND expanding my answer here:
As you noticed, enabling column sorting in Format > Settings works, but selecting a sort in the "Sort Criteria" UI does not.
So, the temporary solution to this is to not use "Sort Criteria" at all, and instead use the Format > settings to sort by the average column. If you don't want to allow the user to click on other columns, just do not click on any of the "Sortable" checkboxes. Only click on the radio button for the average column.
ALTERNATIVELY (a better solution) is to not use Views Aggregator Plus at all, and instead turn on aggregation in the View itself. The benefit of doing this is that the grouping and average calculation is done in the SQL query, rather than in pre-rendering (Views Aggregator's approach). The latter approach can be very resource intensive for large sets of data, as it's highly inefficient. Obviously the Aggregate setting of Views cannot be used in all instances, but I believe it could be used in your example:
That's it. Then your results will be aggregated and sorted correctly. I believe you may need to put your grouping field above the average in the list of fields.