I'm trying to replicate a (buggy) report in Extended Reports, basically:
Campaign | Goal | Amount Raised | Amount Left |
---|---|---|---|
Capital Campaign | $10,000 | $8,000 | $2,000 |
Another Campaign | $15,000 | $6,000 | $9,000 |
The equivalent SQL would be:
SELECT campaign.title as "Campaign", campaign.goal_revenue AS "Goal", SUM(contrib.total_amount) AS "Amount Raised", goal_revenue - SUM(contrib.total_amount) as "Amount Left"
FROM civicrm_campaign campaign
JOIN civicrm_contribution contrib ON campaign.id = contrib.campaign_id
GROUP BY campaign.id;
However, there seems to be no way to do this. SQL transformations won't work because I can't subtract the aggregated Amount Raised from Goal (or do arithmetic transforms on aggregated fields). But Smarty treats the values as strings, with no way to convert to numbers (using intval
filter or casting to (int)
) both generate errors.