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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Jebilaya
Helper III
Helper III

SAMEPERIODLASTYEAR contiguous selection issue

I have a date master table against which my SAMEPERIODLASTYEAR DAX works fine however I have another report so the user can select a rolling 12 month date range (Date Range Selection) which has a 1 - Many relationship back to the date master table.

 

However my sameperiod last year formula does not work when this is presented on visuals.  Any ideas?

 

Relationships as below:

 

Jebilaya_0-1707481280395.png

Works fine when individual year from the date master table is selected

 

Jebilaya_1-1707481370688.png

Does not work if rolling 12 months from date range selection is selected

 

Jebilaya_2-1707481426633.png

 

Dax for LY measure is 

NMR LY = calculate([NMR], SAMEPERIODLASTYEAR('Dim Date Master'[Date]))
Dax for Date range selection is 
Date Range Selection =

Var enddate = max('Fact Safety Stats'[W/C Date])
Var startdate = enddate - 362

Var result =
union(
ADDCOLUMNS(calendar(startdate, enddate), "Selection", "Rolling 12 Months", "Order", "1"),
ADDCOLUMNS(calendar(startdate - 396, startdate - 1), "Selection", "Prior Year", "Order", "2"))

 return
 result
1 REPLY 1
lbendlin
Super User
Super User

Please clarify what "doesn't work"  means.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.