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!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello all,
I have a formula (not time intelligence) to show the Calendar Week (CW) of the previous year (PY).
However the formula doesnt work when I dont have the year in the table, please see below. Is there any tweak I can do to it so that it will still show regardless if the year field is there or not.
Here the formula:
PY CW =
VAR _selectedYear = SELECTEDVALUE('Date'[Year])
VAR _selectedWeek = SELECTEDVALUE('Date'[Week])
RETURN
IF(
NOT ISINSCOPE('Date'[Week]),
CALCULATE(
SUM(Orders[Sales]),
FILTER(
ALL('Date'),
'Date'[Year] = _selectedYear -1
)
),
CALCULATE(
SUM(Orders[Sales]),
FILTER(
ALL('Date'),
'Date'[Year] = _selectedYear -1 &&
'Date'[Week] = _selectedWeek
)
)
)
Also why in the table that is working the totals are not displayed?
Thank you very much!!
Solved! Go to Solution.
Its not wirking as you are using Selected value. So if there is no year column, the selected value is blank. Insted selected value, you may try max of date. Is also not showing the total as at total level your conditions doesnot matches.
Hi, @andicornejo12
You can try the following formula.
PY CW =
VAR _selectedYear =
MAX ( 'Date'[Year] )
VAR _selectedWeek =
MAX ( 'Date'[Week] )
RETURN
IF (
NOT ISINSCOPE ( 'Date'[Week] ),
CALCULATE (
SUM ( Orders[Sales] ),
FILTER ( ALL ( 'Date' ), 'Date'[Year] = _selectedYear - 1 )
),
CALCULATE (
SUM ( Orders[Sales] ),
FILTER (
ALL ( 'Date' ),
'Date'[Year] = _selectedYear - 1
&& 'Date'[Week] = _selectedWeek
)
)
)
If this does not solve your problem, please provide more information about the data.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @andicornejo12
You can try the following formula.
PY CW =
VAR _selectedYear =
MAX ( 'Date'[Year] )
VAR _selectedWeek =
MAX ( 'Date'[Week] )
RETURN
IF (
NOT ISINSCOPE ( 'Date'[Week] ),
CALCULATE (
SUM ( Orders[Sales] ),
FILTER ( ALL ( 'Date' ), 'Date'[Year] = _selectedYear - 1 )
),
CALCULATE (
SUM ( Orders[Sales] ),
FILTER (
ALL ( 'Date' ),
'Date'[Year] = _selectedYear - 1
&& 'Date'[Week] = _selectedWeek
)
)
)
If this does not solve your problem, please provide more information about the data.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Its not wirking as you are using Selected value. So if there is no year column, the selected value is blank. Insted selected value, you may try max of date. Is also not showing the total as at total level your conditions doesnot matches.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 9 | |
| 5 | |
| 4 |
| User | Count |
|---|---|
| 27 | |
| 22 | |
| 20 | |
| 17 | |
| 12 |