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
FilippoV
Helper I
Helper I

SamePeriodLastYear Formula

Hi Community,
I've writing an expression in DAX to calculate the same period of previous year. This is my expression for the current month:
SAMEPERIODLASTYEAR(DATESBETWEEN ( 'Date'[Document Date];"01/03/2017"; TODAY()))

Where TODAY() is 27/03/2017

The problem is that the table result is from 01/03/2016 to 31/03/2016 (not 27/03/2016).

 

Any Ideas?

 

Thanks in advanced

1 ACCEPTED SOLUTION

Hi @v-shex-msft,

thanks for your response.

 

I've observed that if the table Date start from 01/03/2017 to 29/03/2017, not to 28/03/2017 (TODAY), the SamePeriodLastYear works fine.

 

I don't know the reason but it works. 

Smiley Very HappySmiley Very Happy

 

 

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @FilippoV,

 

I can reproduce your issue. The data between function seems works with static value, but I found if you use this function in other method with dynamic value, the function will get the wrong result.

 

I'd like to suggest you manually calculate the date fields at power query side.

 

Notice:

directly use datebetween: both dynamic value and static value works.
Combined datebetween with other method: only static value works.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft,

thanks for your response.

 

I've observed that if the table Date start from 01/03/2017 to 29/03/2017, not to 28/03/2017 (TODAY), the SamePeriodLastYear works fine.

 

I don't know the reason but it works. 

Smiley Very HappySmiley Very Happy

 

 

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.