Sort Reports, List Views or Related Lists by More Than One Column

Some of the oldest and most voted upon ideas on the Salesforce Idea Exchange are the ability to sort Related Lists, List Views and Reports by more than one column.

(Note to Salesforce:  Being old and popular on the Idea Exchange is NOT a good thing.)

So, until Salesforce fixes this, here’s a way you can set up reports or lists to sort on more than one column. It’s not very elegant, but it gets the job done.

This was brought up to me by one of our Sales Managers.  We may have 50 or more contacts at any given Account, but some are contacts that we haven’t worked with in years, so we have marked them inactive.  As a rule, we don’t delete contacts from the Salesforce database.

But this caused the Active, Inactive (and unmarked) Contacts to be sorted together when you sort alphabetically.  If you sort by Status (Active or Inactive), then you lose the alphabetical sort.  Ideally, we’d want Active contacts first, then sorted alphabetically.

So, we created a new text formula field on Contacts called Sort that combines an “A” for active accounts or “Z” with the first 2 letters of the Contact’s last name.  We added that column as the last column on the Contacts related list and on search results layouts, and sorted by that column.

Here’s a screenshot of the Contacts related list on an Account page layout. 

ContactSort

Click image to view full size.

And here’s the formula we used for the Sort field.

if ( ISPICKVAL( Contact_Status__c, “Active”), “A-“& LEFT( LastName , 2) ,
“Z-“& LEFT( LastName , 2))

You can use this approach on any object, and you could set up multiple sort fields per object.
Of course, there are a few limitations and shortcomings of the approach:

  •  You need to anticipate the most common sort combinations your users may need.
  • You’ll be using up one or more custom fields per object.
  • In order to sort by the Sort column, it needs to appear on either the list view, report or related list view.

But until Salesforce fixes this (my guess…. Winter 2016), it’s the best we’ve got!

Leave a comment