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
Anonymous
Not applicable

Sameperiodlastyear for Month is not working

Currently, I have data (January 2020 through February 2021) and when I write this formula:

 

Distinct Headcount = CALCULATE(DISTINCTCOUNTNOBLANK(Table1[EE Number]),DATESMTD(Table1[Date]))
 
I get the count I am expecting for February 2021 as this is my MTD for 2021. But when I try writing a formula  to get my 2020 MTD value, expecting that it will give me the February 2020 count using either SamePeriodLastYear or DateADD, the result I am getting is from December 2020 and not February 2020.
 
I am not using, nor do i want to, a slider for dates. I want to be able to get the distinct count from a year ago which would be February 2020's distinct count.
I have also tried using a calendar table due to the contiguous issue and and I still get the same result-the December 2020 count.
This formula should work and display March counts when I add March 2021 data and bring back March 2020 data.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

I still think the solution can be streamlined, but found a workaround here:

 

Solved: SAMEPERIODLASTYEAR() - Microsoft Power BI Community

 

Thank you @BA_Pete 

View solution in original post

3 REPLIES 3
AntrikshSharma
Community Champion
Community Champion

@Anonymous The problem could be because you are using dates from a fact table, please create a proper date table in your model. For time intelligence calculations there model should always have a proper dates table.

Anonymous
Not applicable

I still think the solution can be streamlined, but found a workaround here:

 

Solved: SAMEPERIODLASTYEAR() - Microsoft Power BI Community

 

Thank you @BA_Pete 

Anonymous
Not applicable

@AntrikshSharma I did create the table and that still did not work. I mention the date table as a calendar table.

 

"I have also tried using a calendar table due to the contiguous issue and and I still get the same result-the December 2020 count."

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.

Top Solution Authors