Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Super User
Super User

@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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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