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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Alex_Hasan
Helper II
Helper II

Last year sales is not matching when compared

Hello, I was comparing total sales of this year vs last year. But look at the picture, In 2011, the last year sales is not matching with 2010. This is my dax formula 

sales LY = CALCULATE( [Total Sales], SAMEPERIODLASTYEAR(DimDate[Date]))

Capture.JPG

What's the problem actually? 

1 ACCEPTED SOLUTION

Yeah, I have deleted it. I found the problem. I mistakenly chose Fiscal Year instead of Calender year (I could not notice it). Now everything is all right with the sales LY = CALCULATE( [Total Sales], SAMEPERIODLASTYEAR(DimDate[Date]))  formula. 

 

Capture.JPG

 

Your last code didn't work actually. But I am grateful to you because you tried to help me a lot. Thank you so much. 

View solution in original post

6 REPLIES 6
HotChilli
Super User
Super User

Was that the right file (I think you might have deleted it now)?
Anyway, try this
Sales PreviousYear = CALCULATE([Total Sales] , DimDate[FiscalYear] = MAX(DimDate[FiscalYear]) -1)

Yeah, I have deleted it. I found the problem. I mistakenly chose Fiscal Year instead of Calender year (I could not notice it). Now everything is all right with the sales LY = CALCULATE( [Total Sales], SAMEPERIODLASTYEAR(DimDate[Date]))  formula. 

 

Capture.JPG

 

Your last code didn't work actually. But I am grateful to you because you tried to help me a lot. Thank you so much. 

HotChilli
Super User
Super User

I disagree with your assessment.  I'm not going to write it for you but I'm trying to give you encouragement.

See my previous post for hint.

HotChilli
Super User
Super User

I was trying to give the algorithm rather than explicit directions for the measure.

Filter arguments are of the form :   column = some value (which uses an aggregation).

You have part of the solution but not all of it.

HotChilli
Super User
Super User

I suspect this is to do with getting a date period shifted back 1 year but what you really want is to subtract one from the Fiscal year filter.  There will be differences of a few days which shows as a difference in the table .

So rewrite the measure without sameperiodlastyear but  subtracting 1 from the fiscal year

Hi @HotChilli , thanks for your response. This is the result showing. 

 

Capture.JPG

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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