Forum Discussion
Sameperiodlastyear funcion issue
Hi Darek
I do have a time dimension table generated by this Dax code:
Date =
VAR BASECALENDAR =
CALENDAR ( DATE ( 2009, 01, 01 ), TODAY () )
RETURN
GENERATE (
BASECALENDAR,
VAR BASEDATE = [DATE]
VAR YEARDATE =
YEAR ( BASEDATE )
VAR MONTHNUMBER =
MONTH ( BASEDATE )
VAR MONTHNAME =
FORMAT ( BASEDATE, "MMMM" )
VAR YEARMONTHNAME =
FORMAT ( BASEDATE, "MMM-YY" )
VAR YEARMONTHNUMBER = ( YEARDATE * 12 + MONTHNUMBER ) - 1
RETURN
ROW (
"DAY", BASEDATE,
"YEAR", YEARDATE,
"MONTH NUMBER", MONTHNUMBER,
"MONTH", MONTHNAME,
"YEAR MONTH NUMBER", YEARMONTHNUMBER,
"YEAR MONTH", YEARMONTHNAME
)
)the sales fact table is linked to this dimension by inv date = dim date
Why would you have cross-filter enabled on the relationship? What's the use of it? You should switch to one-way filtering from dim to the fact table and then see what happens.
- Adidas7 years ago
Helper I
Hi
I've built a demo model to isolate the problem,
it's one to one relationship so I'm forced to set both ways join
however, it has nothing to do with my issue since in the original model it's one-way join and still the same wrong calculation.
I'm starting to believe that Sameperiodlastyear function is context related and was design to work like this
- Anonymous7 years agoNot applicable
Hi there.
Here's the documentation of the function: https://dax.guide/sameperiodlastyear/ as I don't know how I could be of any more help...
Sorry.
Best
Darek