For resources select Search (magnifying glass), Options, Enterprise DNA Online (banner) and use keywords like: virtual tables, countrows, filter, values, calculate and intersect (that could be an alternative).
So I added a YearOffset to your Dates table, this will allow you to select previous years more easily.
Donor in last 3 years =
VAR myTable =
FILTER(
ADDCOLUMNS(
ADDCOLUMNS(
VALUES ( AllRecordedDonationsTable[DonorID] )|
"Y3" | CALCULATE( COUNTROWS( AllRecordedDonationsTable )| FILTER ( ALL ( Dates )| Dates[YearOffset] = -3 ))|
"Y2" | CALCULATE( COUNTROWS( AllRecordedDonationsTable )| FILTER ( ALL ( Dates )| Dates[YearOffset] = -2 ))|
"Y1" | CALCULATE( COUNTROWS( AllRecordedDonationsTable )| FILTER ( ALL ( Dates )| Dates[YearOffset] = -1 )))|
"Last3Y" | IF( [Y3] >0 && [Y2] >0 && [Y1]>0 | TRUE() | FALSE() ))|
[Last3Y] = TRUE()
)
VAR Result = COUNTROWS( myTable )
RETURN Result
And for those donors who are staff or former staff
Donor in last 3 years Former/Staff =
VAR myTable =
FILTER(
ADDCOLUMNS(
ADDCOLUMNS(
VALUES ( AllRecordedDonationsTable[DonorID] )|
"Y3" | CALCULATE( COUNTROWS( AllRecordedDonationsTable )| FILTER ( ALL ( Dates )| Dates[YearOffset] = -3 ))|
"Y2" | CALCULATE( COUNTROWS( AllRecordedDonationsTable )| FILTER ( ALL ( Dates )| Dates[YearOffset] = -2 ))|
"Y1" | CALCULATE( COUNTROWS( AllRecordedDonationsTable )| FILTER ( ALL ( Dates )| Dates[YearOffset] = -1 )))|
"Last3Y" | IF( [Y3] >0 && [Y2] >0 && [Y1]>0 | TRUE() | FALSE() )|
"Staff" | IF( [DonorID] IN VALUES(Former_and_Current_Staff_Table[ID]) | TRUE() | FALSE() ))|
[Last3Y] = TRUE() &&
[Staff] = TRUE()
)
VAR Result = COUNTROWS( myTable )
RETURN Result
Hi @Synergetic, we’ve noticed that no response has been received from you within the last 24 hrs. We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the checkbox. Thanks!
The measures provided in the previous post count the number of DonorID’s that have donated the last 3 or 5 years in a row. Placed in a area chart with the Year on the axis, you’ll get this:
Please note that these measures now have a fixed yearly offset - so they are always measuring a whole calendar year over a whole calendar year.
If you want to track it on a weekly or daily level, that will be easy enough to do with some slight changes to this pattern.
Thanks Melissa
I have verified with a few of the IDs and this is correct.
We want to get ensure that the donor has donated at least once within a calendar year.
I am just trying to find one that has donated several times in a calendar year to check that they are not counted twice.