Forum Discussion
Zx2000
Advocate I
3 years agoSAMEPERDIOLASTYEAR 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
- Greg_Deckler
Community Champion
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-TITHW/m-p/434008