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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Microsoft Employee
Microsoft 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
Microsoft Employee
Microsoft 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.