Forum Discussion
Second Gift Date
- 7 years ago
thanks MitchM , however, it only return the very last gift date, I need it to be able to show the first gift as well, so as in the example below:
Gift Table
Donor ID First donor date Second donor date Third donor date
1234 12/04/2018 15/05/2018
2345 06/04/2018
1111 07/06/2018 12/06/2018 21/08/2018
The end result would be:
Donor ID First donor date Second donor date
1234 12/04/2018 15/05/2018
2345 06/04/2018
1111 07/06/2018 12/06/2018
So not matter if the donor had donated 5 times, I would only want to see the first and second donor date if that makes sense?
Apologies if im confusing you, its almost there and what you have provided does kind of work, but I wouldnt know where to start to fix it.
- 7 years ago
It is no suprise that the filtering does not work. The ranking needs another value (In this case FY) to rank against. To do this you can create a new calc. column called FY:
FY = VAR FirstMonthofFY = 9 VAR DateYear = YEAR( GiftData2[Reformatted Date] ) VAR DateMonth = MONTH( GiftData2[Reformatted Date] ) RETURN IF( DateMonth < FirstMonthofFY, (DateYear - 1) & "/" & DateYear, DateYear & "/" & (DateYear + 1) )I am not sure when your FY starts, so just change the first variable (FirstMonthofFY) in the formula above to adjust the FY range. Once this is done a slight tweak to the Rank formula (below) should finish it off. The two dontation measures do not need to be adjusted.
Gift_Date_Rank = RANKX( FILTER( GiftData2, GiftData2[Donor ID] = EARLIER( GiftData2[Donor ID] ) && GiftData2[FY] = EARLIER( GiftData2[FY] ) ), GiftData2[Reformatted Date], , ASC, Dense ) - 7 years ago
Another question and hopefully the last - once I have the campaign id's and how when the donors gave their 1st and 2nd gift, how would I go about doing a count of how many times the campaign id has appeared, so for example
In 2019 for Jan - there were 200 donors that donated a gift on campaign id "2", out of the 200 donors that gave on campaign id "2", 100 donors gave their second gift on campaign id "3", and 50 donors gave on campaign "4" and 50 donors never gave a second gift..
So its trying to identify out of all the donors that gave their first gift and to which campaign gave again and if it was to a different campaign code or not.
Hope that makes sense
TIA
That is doble, you could use:
Additional Giving In FY =
CALCULATE(
MAX( 'Gift Table'[Gift Date 2] )
)
thanks MitchM , however, it only return the very last gift date, I need it to be able to show the first gift as well, so as in the example below:
Gift Table
Donor ID First donor date Second donor date Third donor date
1234 12/04/2018 15/05/2018
2345 06/04/2018
1111 07/06/2018 12/06/2018 21/08/2018
The end result would be:
Donor ID First donor date Second donor date
1234 12/04/2018 15/05/2018
2345 06/04/2018
1111 07/06/2018 12/06/2018
So not matter if the donor had donated 5 times, I would only want to see the first and second donor date if that makes sense?
Apologies if im confusing you, its almost there and what you have provided does kind of work, but I wouldnt know where to start to fix it.
- MitchM7 years ago
Resolver II
Quick question, because I think I must be missing something. Will your gift table be 2 columns with ID's and Dates or will it be as you showed, with a seperate column for each gift (1,2,3,etc.)? If it is laid out as you show it is there a reason you can not just place the first and second gift columns in a table? If you have a sample pbix file you can share or an excel file with a sample data set that you can share that would be much easier than me guessing :)
- UK_User1234567 years ago
Resolver I
I have put below the sample of exactly how the data will be laid out and highlighted the outcome of what would be displayed in terms of gift 1 and gift 2.
Donor ID Gift ID Gift Date Gift Amount Gift Code Gift Type 1234 111111 12/05/2018 2 Voucher Cash 1234 111112 13/05/2018 15 Voucher Cash 1234 111113 14/05/2018 45 Voucher Cash 1234 111114 15/05/2018 12 Voucher Cash 2344 111115 16/05/2018 100 Gift In Kind Cash 2345 111116 17/05/2018 90 Online Cash 4343 111117 18/05/2018 3.5 Gift In Kind Cash 1111 111118 19/05/2018 50 Online Cash 1111 111119 20/05/2018 9 Online Cash 2222 111120 21/05/2018 10 Gift In Kind Cash 3333 111121 22/05/2018 32 Gift In Kind Cash 3333 111122 23/05/2018 12 Gift In Kind Cash 3333 111123 24/05/2018 34 Online Cash 6666 111124 25/05/2018 54 Online Cash 7777 111125 26/05/2018 76 Gift In Kind Cash 8888 111126 27/05/2018 78 Gift In Kind Cash 8888 111127 28/05/2018 11 Gift In Kind Cash Thank you.
- UK_User1234567 years ago
Resolver I
any help would be greatly appreciated.
- MitchM7 years ago
Resolver II
Ok, I think I got it now. First off, I did go into the query editor and reformat the date to MM/DD/YYYY. This requires creating a calculated column that will rank each date for each donor (Gift_Date_Rank in pic). The measure the calculates the 1st rank (for First Gift) and 2nd rank (for Second Gift).
Hope this makes sense.
CALCULATED COLUMN
Gift_Date_Rank = RANKX( FILTER( GiftData, GiftData[Donor ID] = EARLIER( GiftData[Donor ID] ) ), GiftData[Reformatted Date], , ASC, Dense )First_Donation = CALCULATE( MIN( GiftData[Reformatted Date] ), GiftData[Gift_Date_Rank] = 1 ) Second_Donation = CALCULATE( MIN( GiftData[Reformatted Date] ), GiftData[Gift_Date_Rank] = 2 ) - UK_User1234567 years ago
Resolver I
I will let you know if it has worked next week, but from your screenshot that you have provided, this looks absolutely spot on. Looks very complicated. Are you able to walk me through how the rank works as this is not something I have come across? and so that I can make notes within the calc to be able to remember what it is doing.
On a side note to this, would it be the same calculation or working if I wanted to get the ranking for the last two gift dates?
- MitchM7 years ago
Resolver II
Ranking explained below. If you wanted to get the last 2 dates you would need to create a second calculated column and change from ASC to DESC.
CALCULATED COLUMN
Gift_Date_Rank = RANKX(
// You need to filter down the dataset to the subset you want ranked. In this case it is all the dates where the Donor ID's match
// This is done by saying "Hey Power BI, filter GiftData to this row and any row after it that matches (EARLIER) FILTER( GiftData, GiftData[Donor ID] = EARLIER( GiftData[Donor ID] ) ),
// Next we need to define the value to be ranked, in this case it is the date column GiftData[Reformatted Date], ,
// You want the first gift, so we rank ASC so that the first is 1, second is 2, etc. ASC,
// We now dense rank to account for potential duplicate donations on the same day. The will both be 1, but the second day would be 2 Dense ) - UK_User1234567 years ago
Resolver I
That is an awesome way of doing things and I would never have thought of it. You are awesome so many thanks!
- MitchM7 years ago
Resolver II
No problem! If this works please mark the solution as accepted to close it off. Have a great weekend!
- UK_User1234567 years ago
Resolver I
MitchM- Your calculation works, however one slight problem( table below:) is that, as some donors may have given gifts in 1998 so it is taking this as the first gift, so when I apply a filter for FY 18/19, it is not showing the first gift and second gift correctly also to make things more complicated, the donor could have given 2 gifts on the same day but at different times.
Is there anyway around this?
Gift ID Gift Date Gift Amount Gift Code Gift Type Post Date Donor ID 1 06/04/1998 £10.00 Standing order Cash 12/04/1998 1010 2 08/05/1999 £10.00 Standing order Cash 09/05/1999 1010 3 06/06/2000 £10.00 Standing order Cash 12/06/2000 1010 4 06/07/2004 £10.00 Standing order Cash 14/07/2004 1010 5 06/08/2005 £10.00 Standing order Cash 08/08/2005 1010 6 06/09/2018 £10.00 Standing order Cash 09/09/2018 1010 7 08/10/2018 £10.00 Standing order Cash 21/10/2018 1010 8 06/05/2019 £10.00 Standing order Cash 12/05/2018 1010 9 22/08/2009 £100.00 Direct donation Cash 01/09/2009 202 10 12/06/2018 £235.30 InMem Cash 13/06/2018 202 11 06/05/2019 £10.00 Standing order Cash 22/05/2019 300 12 06/05/2019 £100.00 Direct donation Cash 22/05/2019 300 TIA
- UK_User1234567 years ago
Resolver I
It seems to work with no filters applied, but as soon as I apply a financial year, it then doesnt work.
- MitchM7 years ago
Resolver II
It is no suprise that the filtering does not work. The ranking needs another value (In this case FY) to rank against. To do this you can create a new calc. column called FY:
FY = VAR FirstMonthofFY = 9 VAR DateYear = YEAR( GiftData2[Reformatted Date] ) VAR DateMonth = MONTH( GiftData2[Reformatted Date] ) RETURN IF( DateMonth < FirstMonthofFY, (DateYear - 1) & "/" & DateYear, DateYear & "/" & (DateYear + 1) )I am not sure when your FY starts, so just change the first variable (FirstMonthofFY) in the formula above to adjust the FY range. Once this is done a slight tweak to the Rank formula (below) should finish it off. The two dontation measures do not need to be adjusted.
Gift_Date_Rank = RANKX( FILTER( GiftData2, GiftData2[Donor ID] = EARLIER( GiftData2[Donor ID] ) && GiftData2[FY] = EARLIER( GiftData2[FY] ) ), GiftData2[Reformatted Date], , ASC, Dense ) - UK_User1234567 years ago
Resolver I
holy moly, this would be easier in excel, but im appreciative of all your help
- UK_User1234567 years ago
Resolver I
MitchM- many thanks for helping with this, it has worked wonders, however, if I wanted to show the campaign(s) against these donations, would I need to follow the same path? I would like to show the campaign(s) for both the first donation and second donation?
Thanks
- MitchM7 years ago
Resolver II
No worries! Yes, if you wanted to add an extra dimension to the ranking you would need to add it to the Rank calculated column in a similar way I added FY. Just rember that for every subcategory you add to the rank equation is further slicing down your data. You could always add a second rank column (and additional measures) if you want to rank by another subcategory.
- UK_User1234567 years ago
Resolver I
Another question and hopefully the last - once I have the campaign id's and how when the donors gave their 1st and 2nd gift, how would I go about doing a count of how many times the campaign id has appeared, so for example
In 2019 for Jan - there were 200 donors that donated a gift on campaign id "2", out of the 200 donors that gave on campaign id "2", 100 donors gave their second gift on campaign id "3", and 50 donors gave on campaign "4" and 50 donors never gave a second gift..
So its trying to identify out of all the donors that gave their first gift and to which campaign gave again and if it was to a different campaign code or not.
Hope that makes sense
TIA