cancel
Showing results for
Did you mean:
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
Microsoft

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.

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.
3 REPLIES 3
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?

Post Prodigy

@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.

Microsoft

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.

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.

Announcements

#### 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.

#### 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!

#### 2022 Monthly Feature Releases

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

Top Solution Authors
Top Kudoed Authors