0
votes
+---------+-------+---------+
| NAME    | YEAR  | SCORE   |
+---------+-------+---------+
| A       |  2019 | 100     |
| B       |  2019 | 67      |
| C       |  2019 | 38      |
| A       |  2020 | 48      |
| B       |  2020 | 78      |
| C       |  2020 | 0       |
| A       |  2021 | 0       |
| B       |  2021 | 50      |
| C       |  2021 | 100     |
+---------+-------+---------+

I have a data table with structure below and I am trying to create a card which shows the difference between 2 years (current year - previous year) (which will be affected by Name slicer). However I couldnt seem get achieve below requirements. Is there any ways to achieve this?

  1. if the score for previous year is 0, it will find the difference between current year - non 0 year. Example: if 2019 value is 0, it will find the difference between 2021- 2018.
  2. if the current year is 0, it will compare the last 2 non 0 years. Example: 2021 value is 0, it will compare 2020-2019