cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sanimesa
Post Prodigy
Post Prodigy

SAMEPERIODLASTYEAR does not seem to work if there is a specific date filter

I have the following:

 

Prev Month Sales = CALCULATE(SUM('Sales History'[Sales Amount]), YEAR('Date'[Date])=YEAR(TODAY()), MONTH('Date'[Date]) = MONTH(TODAY()) - 2)

Prev Month Sales LY = CALCULATE ([Prev Month Sales], SAMEPERIODLASTYEAR('Date'[Date] ))

 

Both is returning the values for this year September.  Is the SAMEPERIODLASTYEAR expected to work in this type of cases or am I missing something? 

 

1 ACCEPTED SOLUTION


 

Total Sales LY and YTD Sales LY returns the same value, regardless of other filters applied. Perplexed. 




@sanimesa,

How do you create your visual and what fields do you use to create slicers/filters?

In my scenario, I drag date/year field of Date table and the above measures to a table visual, and create slicers using Year and MonthName fields of Date table,  Total Sales LY and YTD Sales LY return different values.

1.JPG2.JPG


Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
jthomson
Solution Sage
Solution Sage

It's not a function I've used so someone else should have better knowledge but could you not just use the same measure you have for your previous month sales except sticking a -1 in the year section of your measure to get the result you want?

@jthomson I did that for now, but in general the SAMEPERIODLASTYEAR is not behaving as expected. The YTD Last year is returning full last year sum. Data in table seems to be correct.

 

For all of 2016 sales, I am using:

Total Sales LY = CALCULATE(SUM('Sales History'[Sales Amount]), YEAR('Date'[Date])=YEAR(TODAY())-1) 

 

For YTD/YTD LY sales: 

YTD Sales = TOTALYTD(SUM('Sales History'[Sales Amount]), 'Date'[Date]) 

YTD Sales LY = CALCULATE ([YTD Sales], SAMEPERIODLASTYEAR('Date'[Date] ))

 

Total Sales LY and YTD Sales LY returns the same value, regardless of other filters applied. Perplexed. 


 

Total Sales LY and YTD Sales LY returns the same value, regardless of other filters applied. Perplexed. 




@sanimesa,

How do you create your visual and what fields do you use to create slicers/filters?

In my scenario, I drag date/year field of Date table and the above measures to a table visual, and create slicers using Year and MonthName fields of Date table,  Total Sales LY and YTD Sales LY return different values.

1.JPG2.JPG


Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.