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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.