Help with to find donations in one year but not the next.

NeedInformation

New Member
Joined
Feb 23, 2014
Messages
14
Office Version
  1. 2021
Platform
  1. Windows
I'm having a brain cramp with trying to determine the total number (both in dollars and number of unique donors but reported separately) of all donors who gave in the first year but not in the second that live in a certain city. I don't need the donors themselves, just the total of the donations and number of unique donors.

I can sumproduct to find who donated in both. I'm having difficulty in finding who donated in the first year but did NOT donate in the second.

For example if my first year is 2018 and 2017 is the second and looking the City of Dallas I should only find those that are starred which should return a sum of $70 and a count of unique donors as 2

The logic is to find all donations in dallas, then find all who donated in 2018 but not in 2017.

I have a feeling this is a complicated, nested sumproduct but I'm stumped. Any pointers are much appreciated.

All values in any column are not necessarily unique.

DonorIDCityYearDonation
10San Antonio2018$10
10San Antonio2018$20
20Dallas2017$30
20Dallas2018$40
20Dallas2019$40
40Dallas2018$20*
50San Antonio2018$30
50Dallas2017$30
60Dallas2018$30*
60Dallas2018$20*
60San Antonio2018$50
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
365 but would hope to be somewhat backward compatible as others may end up taking over the spreadsheet.

Thanks!
 
Upvote 0
Book1.xlsx
ABCDEFGHIJ
4DonorIDCityYearDonation
510San Antonio201810YearCityUnique Donor in 2018 Not in 2017Sum
610San Antonio2018202018Dallas270
720Dallas201730
820Dallas201840
920Dallas201940
1040Dallas201820
1150San Antonio201830
1250Dallas201730
1360Dallas201830
1460Dallas201820
1560San Antonio201850
Sheet5
Cell Formulas
RangeFormula
I5I5="Unique Donor in "&G6&" Not in "&G6-1
I6I6=SUMPRODUCT(IF(UNIQUE(IFNA(IF(MATCH(IF(B5:B15=H6,IF(C5:C15=G6,A5:A15)),IF(B5:B15=H6,IF(C5:C15=G6-1,A5:A15)),0)>=1,0,1),1)*IF(B5:B15=H6,IF(C5:C15=G6,A5:A15)))>0,1))
J6J6=SUM(INDEX(D5:D15,FILTER(IF(IFNA(IF(MATCH(IF(B5:B15=H6,IF(C5:C15=G6,A5:A15)),IF(B5:B15=H6,IF(C5:C15=G6-1,A5:A15)),0)>=1,0,1),1)*IF(B5:B15=H6,IF(C5:C15=G6,A5:A15))>0,1,0)*(ROW(A5:A15)-ROW(A5)+1),IF(IFNA(IF(MATCH(IF(B5:B15=H6,IF(C5:C15=G6,A5:A15)),IF(B5:B15=H6,IF(C5:C15=G6-1,A5:A15)),0)>=1,0,1),1)*IF(B5:B15=H6,IF(C5:C15=G6,A5:A15))>0,1,0)*(ROW(A5:A15)-ROW(A5)+1)>0)))
 
Upvote 0
I will try to solve without using Dynamic array tommorow as it is already to late
 
Upvote 0
Here is an alternative solution. Using Power Query. Bring your table into PQ. Filter the table for Dallas only. Then duplicate the table. In the first table filter for 2017. In the duplicated table filter for 2018. Now merge the two tables joining them on a left outer join on the User ID. Expand the Table to show the year and Donation amount. The result looks like the following. Backward compatible to 2010.

Book1
ABCDEF
1DonorIDCityYearDonationTable1.YearTable1.Donation
220Dallas201840201730
340Dallas201820
460Dallas201830
560Dallas201820
Sheet3
 
Upvote 0
Could you clarify something, please? Regarding the rule about a donor giving in one year but not another, does it matter at all about the city? For example, donor 60 is shown in three rows, twice in Dallas and once in San Antonio. All three entries are for 2018. If one of the Dallas entries were changed to 2017, then that would negate considering donor 60 for any query regarding Dallas, but would it negate donor 60 for a query involving San Antonio?
 
Upvote 0
City is significant. In the end, there will be a report, by city, summarizing the amount of donations and number of donations given in the first year and not the second. It's to help understand if there is a correlation between the location and increase/decrease of donors. Can't just simply add up all donations in a year and subtract the next. It's an apples-to-apples comparison of a donor in a given city over time.
 
Upvote 0
I'm not sure you understood my question. For all three Donor 60 entries (which are currently shown for 2018)...If one of the Dallas entries were changed to 2017, would that negate donor 60 for a query involving San Antonio? In other words, Donor 60 would have given in 2018 in San Antonio and in 2017 (in Dallas)...would Donor 60 be disqualified from a San Antonio query? Based on your response, in this example I've described, I am guessing that since Donor 60 gave in a different city in 2017, they would still be included in the tally for San Antonio.
 
Upvote 0
Sorry, I did misunderstand. Perhaps I still do.

For donor 60, they gave 3 times in 2018, 2 in Dallas and 1 in San Antonio. Since Donor 60 didn't give in Dallas in 2017 then their two 2018 donations in Dallas count.

Based on your question, if one of the Dallas entries was changed to 2017 then their 2 2018 donations in Dallas would not count and would not, therefore, be considered part of the group who gave in 2018 but not in 2017.

However, if the target city was changed to San Antonio and one of the Dallas contributions was changed to 2017 then Donor 60 would be included becuase they donated in San Antonio in 2018 but not in 2017. Donors 10 and 50 would be counted too, if the target city were changed to San Antonio.
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top