Answers.Body: <p>Ah yes unfortunately you will need some PHP edits to make that work; Custom
  reports in CiviCRM are a good way to start getting into the code base though!</p>
  
  <p>Here's two references for you:
  <a href="https://sf2012.civicrm.org/sites/default/files/slides/CiviCRM%20Reports-Customize%20and%20Extend.pdf" rel="nofollow">https://sf2012.civicrm.org/sites/default/files/slides/CiviCRM%20Reports-Customize%20and%20Extend.pdf</a></p>
  
  <p>and</p>
  
  <p><a href="https://alastaira.wordpress.com/2011/03/17/civicrm-creating-a-custom-report/" rel="nofollow">https://alastaira.wordpress.com/2011/03/17/civicrm-creating-a-custom-report/</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-08T23:56:56.147Z
Answers.LastActivityDate: 2016-06-08T23:56:56.147Z
Answers.UserDisplayName: KarinG - Semper IT
Answers.Body: <p>Those two reports work differently.</p>
  <p>In most reports, there's an array called <code>columns</code> that determines which fields are available.  However, to make reports more standard, there's a simple function &quot;getAddressColumns&quot; a report can call if they just need standard address columns.  Not all reports can use the standard columns, and not all have been converted over (if it ain't broke etc.), but some have.</p>
  <p>Membership Detail report is one of those reports that have been converted - and so it should definitely have the county field.  See screenshot.
  <a href="https://i.sstatic.net/uyPnc.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uyPnc.png" alt="Membership Detail report screenshot" /></a></p>
  <p>Constituent Detail does NOT use that function.  To add the column:</p>
  <ul>
  <li>Edit <code>&lt;civicrmroot&gt;/CRM/Report/Form/Contact/Detail.php</code>.</li>
  <li>In the section <code>civicrm_address</code> (around line 143), add the <code>county_id</code> field to the array.  Copy the style of &quot;state_province_id&quot;.</li>
  <li>That will let you select the column, but it will show as an ID, not the county name.  In the <code>alterDisplay</code> function, copy the state_province_id handling (around line 887) and change all the references to county_id from state_province_id.</li>
  </ul>
  <p>That should at least get your counties displaying!  I'll let KarinG's answer suffice for getting your sorting/grouping working.</p>
  <p>Finally - you can always use exports instead of reports, and group in your favorite spreadsheet program.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-08T05:25:57.690Z
Answers.LastActivityDate: 2016-08-08T05:25:57.690Z
Answers.LastEditDate: 2020-06-17T09:00:50.810Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I'm looking for a way to add sorting and/or grouping by county to reports. Specifically, Membership Details and constituent Details. I've tried a bit of monkeying with the PHP but I don't seem to have a good enough grasp of it. I'm running v4.7.6. Thank you.</p>
  
Tags: <civireport><county>
Title: Add county to reports
ThreadText: # Add county to reports
  
  (Asked by: username_0 on 2016-06-08)
  
  I'm looking for a way to add sorting and/or grouping by county to reports. Specifically, Membership Details and constituent Details. I've tried a bit of monkeying with the PHP but I don't seem to have a good enough grasp of it. I'm running v4.7.6. Thank you.
  
  **Tags:** civireport, county
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-06-08. Score: 1
  
  Ah yes unfortunately you will need some PHP edits to make that work; Custom
  reports in CiviCRM are a good way to start getting into the code base though!
  
  Here's two references for you:
  <https://sf2012.civicrm.org/sites/default/files/slides/CiviCRM%20Reports-Customize%20and%20Extend.pdf>
  
  and
  
  <https://alastaira.wordpress.com/2011/03/17/civicrm-creating-a-custom-report/>
  
  
  ---
  
  ### Answer by username_2 on 2016-08-08. Score: 1
  
  Those two reports work differently.
  
  In most reports, there's an array called `columns` that determines which fields are available. However, to make reports more standard, there's a simple function "getAddressColumns" a report can call if they just need standard address columns. Not all reports can use the standard columns, and not all have been converted over (if it ain't broke etc.), but some have.
  
  Membership Detail report is one of those reports that have been converted - and so it should definitely have the county field. See screenshot.
  [![Membership Detail report screenshot](https://i.sstatic.net/uyPnc.png)](https://i.sstatic.net/uyPnc.png)
  
  Constituent Detail does NOT use that function. To add the column:
  
  * Edit `/CRM/Report/Form/Contact/Detail.php`.
  * In the section `civicrm_address` (around line 143), add the `county_id` field to the array. Copy the style of "state\_province\_id".
  * That will let you select the column, but it will show as an ID, not the county name. In the `alterDisplay` function, copy the state\_province\_id handling (around line 887) and change all the references to county\_id from state\_province\_id.
  
  That should at least get your counties displaying! I'll let KarinG's answer suffice for getting your sorting/grouping working.
  
  Finally - you can always use exports instead of reports, and group in your favorite spreadsheet program.
  
  
  ---
  
  