Answers.Body: <p>We did create additional Summary Fields to cover 1 Apr - Mar 31, and for July 1 - June 30. We then found out that by setting the Financial Year field in civicrm/admin/setting/date?reset=1 to the correct date had the desired outcome. </p>
  
  <p>We therefore made a PR for the extension to improve the documentation to avoid this catching out others unaware.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-27T18:39:01.837Z
Answers.LastActivityDate: 2018-03-27T18:39:01.837Z
Answers.UserDisplayName: petednz - fuzion
Answers.Body: <p>If Summary Fields does not have the fields you need, it's pretty easy to add your own using <code>hook_civicrm_sumfields_definitions()</code></p>
  
  <p>Try dropping something like this into an extension:</p>
  
  <pre><code>/**
   * Implements hook_civicrm_sumfields_definitions().
   *
   */
  function myextension_civicrm_sumfields_definitions(&amp;$custom) {
    $custom['fields']['contribution_count_twelve_months'] = array(
      'label' =&gt; 'Count of Contributions in last 12 months',
      'data_type' =&gt; 'Int',
      'html_type' =&gt; 'Text',
      'weight' =&gt; '15',
      'text_length' =&gt; '32',
      'trigger_sql' =&gt; '(
        SELECT COALESCE(COUNT(id), 0) 
        FROM civicrm_contribution t1
        WHERE t1.contact_id = NEW.contact_id AND t1.contribution_status_id = 1 AND
        t1.financial_type_id IN (%financial_type_ids) AND 
        CAST(receive_date AS DATE) BETWEEN DATE_SUB(NOW(), INTERVAL 12 MONTH) AND NOW()
        )',
      'trigger_table' =&gt; 'civicrm_contribution',
      'optgroup' =&gt; 'fundraising',
    );
  }
  </code></pre>
  
  <p>Tweak the <code>trigger_sql</code> for your preferred time interval.</p>
  
  <p>See the <a href="https://github.com/progressivetech/net.ourpowerbase.sumfields/blob/master/README.md" rel="nofollow noreferrer">Readme</a> for more info.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-26T19:42:21.587Z
Answers.Text: Many thanks Aidan - this is the route we will likely go assuming there is nothing already around. Appreciate the effort put in to providing a useable answer
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-26T10:26:32.763Z
Answers.LastActivityDate: 2018-01-26T10:26:32.763Z
Answers.UserDisplayName: Aidan
Body: <p>I checked the awesome <a href="https://civicrm.org/extensions/summary-fields" rel="nofollow noreferrer">Summary Fields</a> extension and the <a href="https://civicrm.org/extensions/advanced-fundraising-reports" rel="nofollow noreferrer">Advanced Fundraising Reports</a> one but neither seem to quite offer this.</p>
  
  <p>I could do this as a Drupal View but that won't give me the full suite of 'Actions' that might be required.</p>
  
Tags: <civicontribute>
Title: How can i show the Count of Contributions in a give time period?
ThreadText: # How can i show the Count of Contributions in a give time period?
  
  (Asked by: username_0 on 2018-01-25)
  
  I checked the awesome [Summary Fields](https://civicrm.org/extensions/summary-fields) extension and the [Advanced Fundraising Reports](https://civicrm.org/extensions/advanced-fundraising-reports) one but neither seem to quite offer this.
  
  I could do this as a Drupal View but that won't give me the full suite of 'Actions' that might be required.
  
  **Tags:** civicontribute
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2018-03-27. Score: 0 | Accepted answer
  
  We did create additional Summary Fields to cover 1 Apr - Mar 31, and for July 1 - June 30. We then found out that by setting the Financial Year field in civicrm/admin/setting/date?reset=1 to the correct date had the desired outcome.
  
  We therefore made a PR for the extension to improve the documentation to avoid this catching out others unaware.
  
  
  ---
  
  ### Answer by username_1 on 2018-01-26. Score: 0
  
  If Summary Fields does not have the fields you need, it's pretty easy to add your own using `hook_civicrm_sumfields_definitions()`
  
  Try dropping something like this into an extension:
  
  ```
  /**
   * Implements hook_civicrm_sumfields_definitions().
   *
   */
  function myextension_civicrm_sumfields_definitions(&$custom) {
    $custom['fields']['contribution_count_twelve_months'] = array(
      'label' => 'Count of Contributions in last 12 months',
      'data_type' => 'Int',
      'html_type' => 'Text',
      'weight' => '15',
      'text_length' => '32',
      'trigger_sql' => '(
        SELECT COALESCE(COUNT(id), 0) 
        FROM civicrm_contribution t1
        WHERE t1.contact_id = NEW.contact_id AND t1.contribution_status_id = 1 AND
        t1.financial_type_id IN (%financial_type_ids) AND 
        CAST(receive_date AS DATE) BETWEEN DATE_SUB(NOW(), INTERVAL 12 MONTH) AND NOW()
        )',
      'trigger_table' => 'civicrm_contribution',
      'optgroup' => 'fundraising',
    );
  }
  
  ```
  
  Tweak the `trigger_sql` for your preferred time interval.
  
  See the [Readme](https://github.com/progressivetech/net.ourpowerbase.sumfields/blob/master/README.md) for more info.
  
  > **Comments:**
  > **username_0**: Many thanks username_1 - this is the route we will likely go assuming there is nothing already around. Appreciate the effort put in to providing a useable answer  
  
  ---
  
  