Skip to main content
cancel
Showing results for 
Search instead 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.

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
Microsoft Fabric Learn Together

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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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