I have a view which uses the Pivot table format with a first_contact field that contains a year (date format: custom, custom date format: Y), and which is the pivot column of the table.

I want to sort the values of this column according to the year (descending). Additionally, I want to have a No results behavior for the first_contact field saying something like no entry here. This No results behavior column should be positioned at the right of the Year column; after that, there should be a Total column (Row aggregate, in the pivot table settings). This view is included inside a page as a block.

I tried entering the sorting order under the Sort criteria menu header (with year as granularity) as well as inside the pivot table settings (selecting Sortable in the first_contact line and choosing Descending).

In both cases, the view's sorting acts undetermined. When I reload the page with this view, the default sorting changes, apparently seemingly in a random way. Sometimes the NRB column lands between two years, sometimes left, sometimes right. The same thing happens with some view's table lines (random changes of order at reloading). Not all the views show this behavior, though. I cannot figure out the difference between those that do or don't.

All the views use a contextual filter (Provide default value -> *User ID from logged in user`). They don't use a normal filter or a pager, but they use aggregation on some fields.

Does anybody have any hint on how I can set up a sorting order that won't change on reloading?

Edit @jasonflaherty: The SQL query in the preview says ORDER BY label DESC where label is another field. But I suppose that refers to the table lines not columns and should be correct.

Edit: We tested this problem on a Mac system instead of my Linux system, and it works correctly there, strangely (the No Results column appears left of the Total column always).

  • 1
    Are you able to see, in the preview, what the query is sorting on? Just confirming it is date and not something else. Oct 12, 2021 at 16:09
  • Maybe try adding another first_contact field, and set it to Excluded, then sort on this 2nd copy of the field?
    – Beau
    Oct 12, 2021 at 21:31


Your Answer

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

Browse other questions tagged or ask your own question.