Vital Stats Report

Below is the explanation of the standard Vital Stats script.

The numbers produced are not meant to reconcile with your books since the starting and ending dates would not correspond to cutoff dates for bookkeeping.

To customize your own VitalStats:

  • In Special Content create a PythonScript file called VitalStats.

  • Copy the script code from this link: VitalStats.py, or from GitHub

  • Paste that into the PythonScript file you just created.

  • Modify it as you want and save it.

  • If you want to go back to the standard, just delete the VitalStats script you just created.

Explanation of Contribution numbers computed

We use fundid 0 by default which indicates all funds. However, you can limit that to your general tithe fund if you want, by replacing the zero with the appropriate Fund ID#.

48
fund = 0 # 0 is for all funds

Next, we define some terms we will use for date arithmetic to get start and end dates.

50
51
52
53
54
55
56
57
week = 7
weeksinyear = 52
year = weeksinyear * week
oneweekago = week
twoweeksago = week * 2
fiveweeksago = week * 5
oneyearago = year + oneweekago
twoyearsago = year * 2 + oneweekago

In the next two statements, we get the total amounts and counts between the date starting two weeks ago up to one week ago. If today is the 18th, then that would be from the 4th up to the 11th. We do this so that you can run the report on any day of the week and see a full 7 days contributions. Otherwise, you would get an incomplete week if you just looked back 7 days, since data is likely still being entered for the current week

59
60
Data.cnAmtPrev7 = q.ContributionTotals(twoweeksago, oneweekago, fund)
Data.cnCntPrev7 = q.ContributionCount(twoweeksago, oneweekago, fund)

The next two statements get a total count of contributions for 52 weeks. This will be used to get the average size of a gift, not the average total for a donor.

Note

The backslash \ characters indicate the statement continues on the next line.

62
63
64
65
tcount = q.ContributionCount(oneyearago, oneweekago, fund)
Data.cnAvgAmtPerDonorYear = \
    q.ContributionTotals(oneyearago, oneweekago, fund) \
    / tcount if tcount > 0 else 0

The statement gets the weekly average of the total contributions for the past 4 weeks starting 5 weeks ago, up to 1 week ago.

67
68
Data.cnWeekly4WeekAvg = \
    q.ContributionTotals(fiveweeksago, oneweekago, fund) / 4

The next two statements get the weekly average of the total contributions for a year. It compares the most recent year with the year before.

70
71
72
73
Data.cnWeeklyAvgCurrYear = \
    q.ContributionTotals(oneyearago, oneweekago, fund) / weeksinyear
Data.cnWeeklyAvgPrevYear = \
    q.ContributionTotals(twoyearsago, oneyearago, fund) / weeksinyear

These statements allow you to display the date range used which is useful for reconciling the numbers.

75
76
77
78
Data.cnDateRangeCurrYear = \
    q.DateRangeForContributionTotals(oneyearago, oneweekago)
Data.cnDateRangePrevYear = \
    q.DateRangeForContributionTotals(twoyearsago, oneyearago)