Forum Discussion
Event Year YoY Comparison
Say you have a table called Events:
| EventID | Event Name | Event Year |
| 1 | Marathon | 2018 |
| 2 | Race | 2018 |
| 3 | Focking Marathon | 2018 |
| 4 | Marathon | 2019 |
| 5 | Race | 2019 |
| 6 | Focking Marathon | 2019 |
One thing to note: EventID is unique, Event Name is unique within Event Year and the same across Event Years, Event Year is... well, the event's year.
Now, you have another table that stores Donations:
| EventID | Donation Date | Donation Amount |
| 1 | 2017-01-01 | 1 |
| 1 | 2019-01-01 | 2 |
| 1 | 2020-01-01 | -3 |
| 2 | 2017-01-01 | 1 |
| 2 | 2020-01-01 | -1 |
| 3 | 2016-01-01 | 1 |
| ... | ... | ... |
You get the idea. Connect the tables on EventID. Filtering is 1:* from Events to Donations.
Now, you create a measure
[Total Donations] = SUM( Donations[Donation Amount] )
To show donations for the same event but from the year before you do:
[Donations PY] =
var __currentYear = selectedvalue( Events[Event Year] )
return
calculate(
[Total Donations],
Events[Event Year] = __currentYear - 1
)
If you select several Event Names for one year, this will show you the sum of donations for the same events in the prior year. If you select events from several years, it'll show BLANK, as it makes no sense to show PY donations for events from different years at the same time.
Bear in mind that Donations is a fact table and as such should have all columns hidden and in Events only Event Name and Even Year may be exposed.
Best
D