I'm trying to calculate the sales for the previous year in Power BI using DAX formulas, but all the formulas that I've tried are giving me blank values.
Previous Year = CALCULATE([Total], SAMEPERIODLASTYEAR(raw[Inv. Date]))
Previous Year = CALCULATE(
[Total],
FILTER(
raw,
raw[Year] = MAX(raw[Year])-1 &&
raw[Quarter] = MAX(raw[Quarter]) &&
raw[Month] = MAX(raw[Month])
)
)
Previous Year = CALCULATE([Total], DATEADD(raw[Inv. Date], -1, YEAR))
Previous Year = CALCULATE(
[Total],
FILTER(
raw,
raw[Year] = MAX(raw[Year])-1 &&
raw[Quarter] = MAX(raw[Quarter])
&& raw[Month] >= MAX(raw[Month])-11
&& raw[Month] <= MAX(raw[Month])-1
)
)
I also looked at he post: PREVIOUSMONTH returns blank rows or wrong data But I do have a different issue I believe.
This is how my data looks like. The Date is correctly transformed.
However, all these formulas return blank values, even though there is data available for the previous year.
Can anyone suggest what might be causing this issue and how I can fix it? Any help would be greatly appreciated.
Also when I tried to mark it as datetable I get the error that there are not unique values. Not sure if that is the issue.