Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Onaiggac
Frequent Visitor

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.

 

Capturar.PNG

 

Capturar.PNG

 

But for quarter view, some how, AnoPre sums all value from last period and actual period and my variation gets a wrong value.

Capturar.PNG

 

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?

 

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
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. Smiley Happy

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Employee
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. Smiley Happy

 

Regards

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/22...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.