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
arif_ali
Frequent Visitor

SamePeriodLastYear is not working for Sales Calendar

Hello,
I have a date table and each date is tagged for sales calendar month. the field called "Sale Month-Year"

Last year my July sales calendar started from 7/1/2022 and ended on 8/1/2022 whereas this year July 2023 started from 7/1/2023 and going to end 7/31/2023. When I run samperiodlastyear function, it only picks data from 7/1/2022 to 7/31/2022 and misses 8/1/2022. 

 

When I filter for July 2023, how can I pick last year data where "Sale Month-Year" is July 2022 (including 8/1/2022)?

 

Thank you in advance!

 

Arif

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @arif_ali 

You can refer to the following example .

Sampel data 

Last_year

vxinruzhumsft_0-1689214694567.png

 

This_year

vxinruzhumsft_1-1689214709275.png

 

Then create a measure

Measure = var a=EOMONTH(MAXX(ALLSELECTED(This_year),[Date]),-13)+1
var b=EOMONTH(MAXX(ALLSELECTED(This_year),[Date]),-12)+1
return IF(SELECTEDVALUE(Last_year[Date])>=a&&SELECTEDVALUE(Last_year[Date])<=b,1,0)

Output

vxinruzhumsft_2-1689215174451.png

Best Regards!

Yolo Zhu

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

1 REPLY 1
v-xinruzhu-msft
Community Support
Community Support

Hi @arif_ali 

You can refer to the following example .

Sampel data 

Last_year

vxinruzhumsft_0-1689214694567.png

 

This_year

vxinruzhumsft_1-1689214709275.png

 

Then create a measure

Measure = var a=EOMONTH(MAXX(ALLSELECTED(This_year),[Date]),-13)+1
var b=EOMONTH(MAXX(ALLSELECTED(This_year),[Date]),-12)+1
return IF(SELECTEDVALUE(Last_year[Date])>=a&&SELECTEDVALUE(Last_year[Date])<=b,1,0)

Output

vxinruzhumsft_2-1689215174451.png

Best Regards!

Yolo Zhu

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.