cancel
Showing results 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.

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
Employee

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.

Employee

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

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

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors