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
Zx2000
Advocate I
Advocate I

SAMEPERDIOLASTYEAR strange result

I am not going prsent the whole picture of calculations as it has no point so... going straigt to the point.

My date table ends at 27.01.2023. If I create a table with DETESYTD it has 27 records - correct and clear. But when I create another table based on this previous table and with SAMEPPERIODLASTYEAR it results with 31 records from a year before? WHY? Why not 27?  It should result in same number of days like in the first table provided to calculations but with year shifted -1 (2022) for every single record (27). It results in all dates from January from previous year (31).  


test 1 =
VAR x1 = DATESYTD(Daty[Date]) -- There are 27 days in my January date table for 2023 (correct). So this table  contains 27 rows
VAR x2 = COUNTROWS(x1)--it equals 27
VAR x3 = SAMEPERIODLASTYEAR(x1) -I hope for the first table but with year -1 
VAR x4 = COUNTROWS(x3) -- it equals 31. Why? It should be 27 by with year -1
RETURN
x4
1 REPLY 1
Greg_Deckler
Super User
Super User

@Zx2000 You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.