Forum Discussion
Issue with SAMEPERIODLASTYEAR in Enhanced DAX Time Intelligence (Preview) Week 53 returns incorrect
Hello v-dineshya ,
Thank for the detailed explanation.
As shown in the highlighted image, dateadd function worked correctly , it retuned null values. However the only issue with this it inflates the LY sales by 6 times as highlighted in the above image in red.
OFFSET functionality doesnt seem to work. Either it is not able to identify the YEAR parameter (Parameter is not correct type) and also it is not able to identiy 'Date(454)' table as it is mapped internally to DimDate.
In addition to this , I'm working on creating a DatePeriod slicer (LW, MTD, QTD, STD, WTD, YESTERDAY, YTD) that interacts with Date Range Slicer and Measures.
The DatePeriod Tabe has "Date" ,Period columns.
Relationship is defined as DatePeriod (Many) to One (DimDate) and cross filtered on both directions.
However when a particular period is selected , it doesnt return any values for LY Sales
The measure defintion remains same as in the above post. I used RemoveFilters to remove the context however it dint work. Could you please help me resolve this issue ?
Thanks,
Pratyusha
Hi bpratyusha ,
Please try below two options for LY measure.
1. Your table is DimDate, but the Enhanced Calendar object is called Date(454). However OFFSET must always reference DimDate, NOT the name of the calendar object.
LY Sales =
CALCULATE(
SUM('fact'[sales]),
OFFSET(
-1,
ORDERBY(DimDate[fiscal_day_in_year]),
MATCHBY(DimDate[fiscal_year]),
DEFAULT
)
)
2. LY based on fiscal_year – 1 + same fiscal_day_in_year.
LY Sales =
VAR CurrentFiscalYear =
SELECTEDVALUE ( DimDate[fiscal_year] )
VAR CurrentFiscalDay =
SELECTEDVALUE ( DimDate[fiscal_day_in_year] )
VAR TargetFiscalYear =
CurrentFiscalYear - 1
RETURN
CALCULATE (
SUM ( Fact[sales] ),
KEEPFILTERS (
FILTER (
ALL ( DimDate ),
DimDate[fiscal_year] = TargetFiscalYear
&& DimDate[fiscal_day_in_year] = CurrentFiscalDay
)
)
)
Your DatePeriod slicer breaks LY because of bidirectional relationships. Use SINGLE-direction relationship instead of bidirectional relationships.
Cross filter direction, Single (DatePeriod --> DimDate)
DATEADD & SAMEPERIODLASTYEAR ARE NOT SUPPORTED for custom calendars. It is a limitation. We would recommend submitting your detailed feedback and ideas through Microsoft's official feedback channels, such as Microsoft Fabric Ideas. Feedback submitted through these channels is frequently reviewed by the product teams and can contribute to meaningful improvements.
https://ideas.fabric.microsoft.com/ideas/search-ideas/
Some members havesubmitted ideas regarding SAMEPERIODLASTYEAR function in ideas forum. Please refer below link, if any idea is related to your query please upvote the particluar idea.
Search - Microsoft Fabric Community
Thank you for being a valued member in Microsoft Fabric Community Forum
Regards,
Dinesh
- v-dineshya9 months ago
Community Support
Hi bpratyusha ,
We haven’t heard from you on the last response and was just checking back to see , Could you please confirm if you've submitted this as an idea in the Ideas Forum? If so, sharing the link here would be helpful for other community members who may have similar feedback. Thank you for being part of the Microsoft Fabric Community.
Regards,
Dinesh
- bpratyusha9 months agoRegular Visitor
Hello v-dineshya ,
Thank you for the recommendations. I tried to implemented yet I'm blocked on the issue.
1. LY Sales (offset) functionality dint really work. ORDERBY and MATCHBY is not recognizing DimDate table and its attributes. Also there is no DEFAULT.
2. LY based on fiscal_year – 1 + same fiscal_day_in_year. The recommended measure also dint work. It returned blank values.
The measure worked when KEEPFILTERS is removed.
3. Cross filter direction, Single (DatePeriod --> DimDate). I changed it to Single then tested it dint workI'm not sure how to set the Signle direction of the filter from date period to dimDate.
I will submit an idea in the feedback channel so that the product team can work on the improvements.Thanks,
Pratyusha
- v-dineshya9 months ago
Community Support
Hi bpratyusha ,
Thank you for the update. Once you submitted the idea, please share the link here would be helpful for other community members who may have similar feedback. Thank you for being part of the Microsoft Fabric Community.
Regards,
Dinesh