Forum Discussion
Summarize table wrong measure results
It seems like the issue arises from the calculation of the "Baseline Budget Price (Prod) €" measure when there are missing years in the data. When a year is missing, the measure doesn't aggregate correctly because it relies on specific year-based calculations.
To address this issue, you can modify the measure to handle cases where data for previous years is missing. You can use the LASTNONBLANK function to retrieve the last available price before the current year and then apply the inflation factor.
Here's how you can modify the "Baseline Budget Price (Prod) €" measure:
```DAX
Baseline Budget Price (Prod) € =
VAR CurrentYear = SELECTEDVALUE('PO Schedule'[Delivery Year])
VAR LastYearPrice = CALCULATE([Mode € (Production)], FILTER(ALL('PO Schedule'[Delivery Year]), 'PO Schedule'[Delivery Year] < CurrentYear), LASTNONBLANK('PO Schedule'[Mode Production], [Mode Production]))
RETURN
IF(
NOT ISBLANK(LastYearPrice),
LastYearPrice * (1 + [Inflation]),
[Mode € (Production)]
)
```
This modified measure calculates the "Baseline Budget Price (Prod) €" by finding the last available price from the previous years using the LASTNONBLANK function. If there is no available price from the previous years, it defaults to the current year's price. Then, it applies the inflation factor to the last available price.
This approach should provide more accurate results even when there are missing years in the data.
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!