This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hi,
I would like to calculate previous year's value, but I only get the correct number if I don't apply any slicer or filter.
The result I need is in the Total LY or in Total LY exact date column in below table
| Year | Total CY | Total LY | Total LY exact date |
| 2017 | 121 | ||
| 2018 | 219 | 121 | 121 |
| 2019 | 179 | 219 | 208 |
| Total (shown when the measure is displayed as single value such as in KPI Card) | 179 | 219 | 208 |
The scenario is that 2019 is still the current year of the data, thus the latest transaction date is not 31 Dec 2019, but before, let's say 27 Aug 2019.
Total LY shows the measurement at the end of the year, which is 31 Dec 2018 and 31 Dec 2017.
Total LY exact date shows the measurement at the same date of the each previous year, which is 27 Aug 2018 and 27 Aug 2017.
I managed to show the Total LY and Total LY exact date, if I use a single value visual, such as KPI card. And when I apply filter/slicer of a certain date, even though 2019, it showed blank value. There must be something I missed in the formula. Hope that I can get help on what is missed out and the correct formula.
To get the picture of what happened, here's the formula I used to get Total LY. The formula for Total LY exact date is similar, just a slight change on the filter date used. Appreciate if there's any input on this formula also
@RVLee , Not sure why you are using max date
Try like
CALCULATE (
lastnonblankvalue ( 'Production'[Production Date],SUM ( 'Contract'[Amount] ) ),
DATESYTD ( SAMEPERIODLASTYEAR ( 'Calendar Date'[Date] ) )
)
Can explain with example what is wrong
Hi @amitchandak
I used max date to get the latest transaction date from Production table, and sometimes the latest transaction date of production in each location is different.
While the amount to sum is in the Contract table, which contains the transaction of contracts of all periods, even future dates.
Both dates have a one-to-many relationship to Calendar table.
Tried your suggestion, however it returns incorrect number. Any other suggestion?
Regards,
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 31 | |
| 25 | |
| 21 | |
| 18 | |
| 17 |
| User | Count |
|---|---|
| 62 | |
| 34 | |
| 33 | |
| 25 | |
| 24 |