Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi guys,
I'm trying to use SAMEPERIODLASTYEAR to see selected week based on slicer for This Year (TY) and Last Year (LY), however, when I select the week, it seems to reflect in TY column only but not in LY column as screenshot below (example here is I selected week 4)
I am trying to ensure that LY Week Selected also shows the number that is filtered in "Week" Slicer (or Max number of week if multiple weeks are selected in Slicer)
TY Week Selected =
if(ISFILTERED('Calendar Table'[Week Number]),MAX('Calendar Table'[Week Number]),MAX('Sales Table'[Latest Week Number]))LY Week Selected = CALCULATE([Dummy Value],SAMEPERIODLASTYEAR('Calendar Table'[Date]))
Solved! Go to Solution.
Hi,
I am not sure if I understood your question correctly, but when searching for last year's same week number value, please try something like below.
LY selected week sales: =
VAR _currentyear =
MAX ( 'calendar'[Year] )
VAR _lastyear = _currentyear - 1
VAR _selectedweeknumber =
MAX ( 'calendar'[Week number] )
VAR _lastyearperiod =
FILTER (
ALL ( 'calendar' ),
'calendar'[Year] = _lastyear
&& 'calendar'[Week number] = _selectedweeknumber
)
RETURN
IF (
HASONEVALUE ( 'calendar'[Year] ),
CALCULATE ( [This year selected week sales:], _lastyearperiod )
)
Hi,
I am not sure if I understood your question correctly, but when searching for last year's same week number value, please try something like below.
LY selected week sales: =
VAR _currentyear =
MAX ( 'calendar'[Year] )
VAR _lastyear = _currentyear - 1
VAR _selectedweeknumber =
MAX ( 'calendar'[Week number] )
VAR _lastyearperiod =
FILTER (
ALL ( 'calendar' ),
'calendar'[Year] = _lastyear
&& 'calendar'[Week number] = _selectedweeknumber
)
RETURN
IF (
HASONEVALUE ( 'calendar'[Year] ),
CALCULATE ( [This year selected week sales:], _lastyearperiod )
)
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 132 | |
| 88 | |
| 82 | |
| 68 | |
| 64 |