Answers.Body: <p>Well, I started to give an answer, then started digging, and eventually found a bug that affects this particular situation.  I've reported it as <a href="https://lab.civicrm.org/dev/report/issues/6" rel="nofollow noreferrer">reporting#6</a> and <a href="https://github.com/civicrm/civicrm-core/pull/12808" rel="nofollow noreferrer">submitted a fix</a>.</p>
  
  <p>It turns out that <code>address_name</code> is defined twice, accidentally.  The first time it's correct; the second time is incorrect, and prevents the address name from being sortable.</p>
  
  <p>I've submitted a fix, which should be in the 11/7/2018 release (CiviCRM 5.7) - but for now, open <code>CRM/Report/Form.php</code> in your CiviCRM root and delete <a href="https://github.com/civicrm/civicrm-core/blob/master/CRM/Report/Form.php#L5517-L5522" rel="nofollow noreferrer">lines 5517-5522</a>.  Note how <code>street_name</code> is <a href="https://github.com/civicrm/civicrm-core/blob/master/CRM/Report/Form.php#L5478-L5486" rel="nofollow noreferrer">also defined earlier</a>, with <code>is_order_bys</code> set to TRUE, which makes it available for sorting.</p>
  
  <p>To answer your other questions:</p>
  
  <ul>
  <li>Custom fields will be available for sorting (and in reports generally) if the "Searchable" option is selected for the field.</li>
  <li>There's no shame in connecting a third-party MySQL reporting tool to CiviCRM!  If you use Drupal, you already have a great one in Views; other folks like Tableau and Pentaho BI.  A dedicated reporting tool will always be a great choice.</li>
  </ul>
  
  <p>Some additional thoughts:</p>
  
  <ul>
  <li>Not every report uses this function to determine the fields to include!  In olden days, each report defined its own address fields; now the best practice is to use this function.  This fixes a bunch of reports, but not 100% of them.  Notably, it fixes "Constituent Sumamry" and "Walk List".</li>
  <li>Check out the Walk List report, aka "Survey Report (Detail)", since I suspect you're doing a walk list.</li>
  <li>If you ARE doing a walklist, upgrade to CiviCRM 5.5+, because there's a bug fix that lets you sort by odd/even street numbers.</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-12T07:52:39.067Z
Answers.Text: If you are a Drupal user then I endorse Jon's comment about Drupal Views.  Worth spending some time on it - it's very powerful
Answers.UserDisplayName: Andy Clark
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-12T03:40:01.870Z
Answers.LastActivityDate: 2018-09-12T03:53:18.577Z
Answers.LastEditDate: 2018-09-12T03:53:18.577Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I'm trying to run a contact report which sorts by Street Name, but it's not available as a sort option, and the list of options available seem abitrary and vary depending on the base report I use.  </p>
  
  <p>Strangely enough, Street Number is available as a sort option, which is definitely useful, but not so useful without Street Name.  Some of the custom fields that I've created are also visible, but not all of them.</p>
  
  <p>Things I've tried:</p>
  
  <ul>
  <li>Checking to make sure address parsing is turned on (it is, and the street_name column is populated in the database with valid data)</li>
  <li>Adding the street name column to the report to make it viewable</li>
  <li>Trying an assortment of different contact reports as the base report to start from</li>
  </ul>
  
  <p>I'm not sure where to go from here and am really not happy with how convoluted civireport is.  I'm on the verge of starting to look into third party mysql reporting tools to accomplish this and would rather not if I could avoid it.</p>
  
  <p>Does anyone have any suggestions?  What determines whether or not a column appears in the sorting tab?</p>
  
Tags: <civireport>
Title: Columns available for sorting in CiviReport seem arbitrary/random
ThreadText: # Columns available for sorting in CiviReport seem arbitrary/random
  
  (Asked by: username_0 on 2018-09-12)
  
  I'm trying to run a contact report which sorts by Street Name, but it's not available as a sort option, and the list of options available seem abitrary and vary depending on the base report I use.
  
  Strangely enough, Street Number is available as a sort option, which is definitely useful, but not so useful without Street Name. Some of the custom fields that I've created are also visible, but not all of them.
  
  Things I've tried:
  
  * Checking to make sure address parsing is turned on (it is, and the street\_name column is populated in the database with valid data)
  * Adding the street name column to the report to make it viewable
  * Trying an assortment of different contact reports as the base report to start from
  
  I'm not sure where to go from here and am really not happy with how convoluted civireport is. I'm on the verge of starting to look into third party mysql reporting tools to accomplish this and would rather not if I could avoid it.
  
  Does anyone have any suggestions? What determines whether or not a column appears in the sorting tab?
  
  **Tags:** civireport
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-09-12. Score: 3 | Accepted answer
  
  Well, I started to give an answer, then started digging, and eventually found a bug that affects this particular situation. I've reported it as [reporting#6](https://lab.civicrm.org/dev/report/issues/6) and [submitted a fix](https://github.com/civicrm/civicrm-core/pull/12808).
  
  It turns out that `address_name` is defined twice, accidentally. The first time it's correct; the second time is incorrect, and prevents the address name from being sortable.
  
  I've submitted a fix, which should be in the 11/7/2018 release (CiviCRM 5.7) - but for now, open `CRM/Report/Form.php` in your CiviCRM root and delete [lines 5517-5522](https://github.com/civicrm/civicrm-core/blob/master/CRM/Report/Form.php#L5517-L5522). Note how `street_name` is [also defined earlier](https://github.com/civicrm/civicrm-core/blob/master/CRM/Report/Form.php#L5478-L5486), with `is_order_bys` set to TRUE, which makes it available for sorting.
  
  To answer your other questions:
  
  * Custom fields will be available for sorting (and in reports generally) if the "Searchable" option is selected for the field.
  * There's no shame in connecting a third-party MySQL reporting tool to CiviCRM! If you use Drupal, you already have a great one in Views; other folks like Tableau and Pentaho BI. A dedicated reporting tool will always be a great choice.
  
  Some additional thoughts:
  
  * Not every report uses this function to determine the fields to include! In olden days, each report defined its own address fields; now the best practice is to use this function. This fixes a bunch of reports, but not 100% of them. Notably, it fixes "Constituent Sumamry" and "Walk List".
  * Check out the Walk List report, aka "Survey Report (Detail)", since I suspect you're doing a walk list.
  * If you ARE doing a walklist, upgrade to CiviCRM 5.5+, because there's a bug fix that lets you sort by odd/even street numbers.
  
  > **Comments:**
  > **username_2**: If you are a Drupal user then I endorse Jon's comment about Drupal Views.  Worth spending some time on it - it's very powerful  
  
  ---
  
  