Forum Discussion
SAMEPERIODLASTYEAR goes wrong for quarter
I have two main calculated columns.
The first one is for calculate using the SAMEPERIODLASTYEAR function.
AnoPre = CALCULATE(SUM(vw_VariacaoTotalResiduosXCategoria[Peso(t)]); SAMEPERIODLASTYEAR(DatasParaBI[Date]))
And the variation expression
Δ = IFERROR((SUM(vw_VariacaoTotalResiduosXCategoria[Peso(t)]) - [AnoPre])/SUM(vw_VariacaoTotalResiduosXCategoria[Peso(t)]);BLANK())
The table DatasParaBI is my date table and the vw_VariacaoTotalResiduosXCategoria is my SQL view that return my data.
It works good when see the grid for months and years.
But for quarter view, some how, AnoPre sums all value from last period and actual period and my variation gets a wrong value.
For this item on first quarter period (months 1, 2 and 3 from 2016) should return 43.939,737. But its summing with 86.005,83 (actual first quarter period from 2017).
Maybe its something wrong with my AnoPre column?
Hi Onaiggac,
According to your description above, I think the measure AnoPre is correct, and it should work. The problem should be related to your Quarter column.
From the screenshots you posted above, you have a month called "Jan/17" for 2017 Jan, but the quarter "First" for 2017 Q1? Shouldn't it be "First/2017"? So you may need to change the values for Quarter correctly to make it work. :smileyhappy:
Regards
2 Replies
- v-ljerr-msftMicrosoft Employee
Hi Onaiggac,
According to your description above, I think the measure AnoPre is correct, and it should work. The problem should be related to your Quarter column.
From the screenshots you posted above, you have a month called "Jan/17" for 2017 Jan, but the quarter "First" for 2017 Q1? Shouldn't it be "First/2017"? So you may need to change the values for Quarter correctly to make it work. :smileyhappy:
Regards
- OnaiggacAdvocate II
Sure.
Because the actual column and last pariod column has the same name and thats why its summing.
Its working.
Tks.
Now I having a problem to use filter. Its says something like "Exception generated by IDataReader interface."
But I will create another post https://community.powerbi.com/t5/Desktop/SAMEPERIODLASTYEAR-with-filter-return-error-message/td-p/220353