CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • End of Year Donation Summary Report
Pages: [1]

Author Topic: End of Year Donation Summary Report  (Read 981 times)

RicardoDavis

  • I’m new here
  • *
  • Posts: 29
  • Karma: 0
  • CiviCRM version: 4 (yay!)
  • CMS version: 7
  • MySQL version: 5.1
  • PHP version: 5.2
End of Year Donation Summary Report
November 14, 2011, 08:53:37 am
I got a request today for an end-of-year donation summary report for a specific contribution type.  The Donor Report (Summary) would fit the bill but it doesn't appear that I can have the report return the contact information (name, email, phone, postal greeting) and filter by date range.  I would think this would be a standard report for any donor management package.  Can someone give me a pointer on how to do this?

RicardoDavis

  • I’m new here
  • *
  • Posts: 29
  • Karma: 0
  • CiviCRM version: 4 (yay!)
  • CMS version: 7
  • MySQL version: 5.1
  • PHP version: 5.2
Re: End of Year Donation Summary Report
November 14, 2011, 01:01:48 pm
Here's the SQL query I wrote to give me what I want:

Quote
USE supporx4_civicrm;

-- Individual contributions
SELECT
--    CD.contribution_type_id, CD.source,
    CD.contact_id, C.display_name AS contact, C.first_name, C.last_name
    , C.is_opt_out, P.phone, C.do_not_phone
    , C.email_greeting_display, E.email, C.do_not_email
    , C.postal_greeting_display, A.street_address, A.supplemental_address_1, A.city, S.abbreviation AS state, A.postal_code AS zip_code, A.postal_code_suffix AS zip_plus_4
    , CD.receive_date, CD.total_amount
    , `COUNT(id)` AS num_contact_contributions, `SUM(total_amount)` AS sum_total_contact_contributions
FROM civicrm_contribution CD
    INNER JOIN civicrm_contact C ON CD.contact_id = C.id
    LEFT OUTER JOIN civicrm_address A ON CD.contact_id = A.contact_id AND A.is_primary = 1
    LEFT OUTER JOIN civicrm_state_province S ON A.state_province_id = S.id
    LEFT OUTER JOIN civicrm_phone P ON CD.contact_id = P.contact_id AND P.is_primary = 1
    LEFT OUTER JOIN civicrm_email E ON CD.contact_id = E.contact_id AND E.is_primary = 1
    INNER JOIN (
        SELECT
        contact_id
        , COUNT(id)
        , SUM(total_amount)
        FROM civicrm_contribution
        WHERE
            contribution_type_id IN (1, 5, 8 )
            AND receive_date BETWEEN '2011-01-01 00:00:00' AND '2011-12-31 23:59:59'         -- Calendar year 2011
        GROUP BY
            contact_id
    ) AS CDT ON CD.contact_id = CDT.contact_id
WHERE
    CD.contribution_type_id IN (1, 5, 8 )
    AND CD.receive_date BETWEEN '2011-01-01 00:00:00' AND '2011-12-31 23:59:59'     -- Calendar year 2011
ORDER BY
    CD.contact_id
    , CD.receive_date ASC
;

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: End of Year Donation Summary Report
November 14, 2011, 08:52:41 pm
You can easily write an extension (custom report) as described in our book:

http://en.flossmanuals.net/civicrm-developer-guide/reports/
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • End of Year Donation Summary Report

This forum was archived on 2017-11-26.