Often we need to derive donor with multiple gifts grouped by other dimensions. In the example below, I am adding a count of donors in a specified range from a zip code who made multiple donations. The dashboard example is available here.
Let’s review the code that generates the measure.
Donors With Mult. Gifts =
VAR DonorsMultDonations =
FILTER (
‘Main Donor Table’,
CALCULATE ( DISTINCTCOUNT ( ‘Contribution Details'[Contribution ID] ) ) > 1
)
VAR MultDonorsinRange =
FILTER ( DonorsMultDonations, ‘Main Donor Table'[Distance in Range] = 1 )
RETURN
COUNTROWS ( MultDonorsinRange )
The first variable iterates over the main donor table. For each donor record, it references the Contribution Detail table and evaluates if a unique count of gifts is greater than 1.
‘Main Donor Table’,
CALCULATE ( DISTINCTCOUNT ( ‘Contribution Details'[Contribution ID] ) ) > 1
)
The second variable filters the main donor table to keep only donors who are within the zip code range.
VAR MultDonorsinRange =
FILTER ( DonorsMultDonations, ‘Main Donor Table'[Distance in Range] = 1 )
The final portion of the code counts twice-filtered Main Donor table.