Forum Discussion
Can't get the KPI visual to work correctly
Anonymous , Try like
RevenueCY = CALCULATE([Revenue],filter('Calendar', 'Calendar'[Year] = YEAR(TODAY()) ))
RevenuePY = CALCULATE([Revenue],filter('Calendar', 'Calendar'[Year] = YEAR(TODAY())-1 ))
or
other example
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
//Only year vs Year, not a level below
This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))
Make sure calendar is marked as date table
Thanks for the tips. I used the following suggestions:
RevenueCY = CALCULATE([Revenue],filter('Calendar', 'Calendar'[Year] = YEAR(TODAY()) ))
RevenuePY = CALCULATE([Revenue],filter('Calendar', 'Calendar'[Year] = YEAR(TODAY())-1 ))
But two things are not going according to plan.
1) In the KPI visual it correctly shows the current Revenue, however the target is still showing (Empty).
When I convert the visual to a table it looks like this, that's probably the reason it fails. It's showing 2021 and compares it to zero (bottomright field).
| Year | RevenueCY | RevenuePY |
| 2020 | 14.92 Mil | |
| 2021 | 14.12 Mil |
2) However the RevenuePY is also incorrect, it shows the total revenue of 2020, not from 1-1-2020 until 11-11-2020.
Any additional tips?