Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin 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.
I'm trying to filter and get "last week data" based on latest dataset.
e.g. if my latest input is on January 16(Week 3) I want data from January 8 to January 14(Week 2)
This function works
However when I want to add Year as a condition it fails to run.
Solved! Go to Solution.
A) The formula to the measure has to be adjusted.
B) Check this post solution
https://community.powerbi.com/t5/Desktop/DAX-function-to-show-last-weeks-visits/m-p/2140649
C) FYI, CALCULATETABLE returns table. You need to add something to use and get what you want later ... Check this for the sample on how to use SUMX
https://docs.microsoft.com/en-us/dax/calculatetable-function-dax
Additional links to get last week:
https://amitchandak.medium.com/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://www.daxpatterns.com/week-related-calculations/
https://www.vahiddm.com/post/weekly-time-intelligence-dax
Typical Measures, we all do with week
Current Week =
var _Dt = MAX([Date])
var _Week = WEEKNUM(_Dt)
var _Year = YEAR(_Dt)
RETURN _Year & "-" & _Week
Latest Week Sales 2 = CALCULATE(Sum(SalesFact[Revenue]), FILTER('Date', YEAR('Date'[Date]) & "-" & WEEKNUM('Date'[Date]) = SalesFact[Last Week]))
(or)
Latest Week Sales =
var _Dt = MAX([Date])
var _Week = WEEKNUM(_Dt)
var _Year = YEAR(_Dt)
RETURN CALCULATE(Sum(SalesFact[Revenue]), FILTER('Date', and(WEEKNUM('Date'[Date]) = _Week, YEAR('Date'[Date]) = _Year)))
for quick testing, can you check what you are getting values for
MAXX('Table','Table'[WeekNum])
MAXX('Table','Table'[Year])
I got "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value."
A) The formula to the measure has to be adjusted.
B) Check this post solution
https://community.powerbi.com/t5/Desktop/DAX-function-to-show-last-weeks-visits/m-p/2140649
C) FYI, CALCULATETABLE returns table. You need to add something to use and get what you want later ... Check this for the sample on how to use SUMX
https://docs.microsoft.com/en-us/dax/calculatetable-function-dax
Additional links to get last week:
https://amitchandak.medium.com/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://www.daxpatterns.com/week-related-calculations/
https://www.vahiddm.com/post/weekly-time-intelligence-dax
Typical Measures, we all do with week
Current Week =
var _Dt = MAX([Date])
var _Week = WEEKNUM(_Dt)
var _Year = YEAR(_Dt)
RETURN _Year & "-" & _Week
Latest Week Sales 2 = CALCULATE(Sum(SalesFact[Revenue]), FILTER('Date', YEAR('Date'[Date]) & "-" & WEEKNUM('Date'[Date]) = SalesFact[Last Week]))
(or)
Latest Week Sales =
var _Dt = MAX([Date])
var _Week = WEEKNUM(_Dt)
var _Year = YEAR(_Dt)
RETURN CALCULATE(Sum(SalesFact[Revenue]), FILTER('Date', and(WEEKNUM('Date'[Date]) = _Week, YEAR('Date'[Date]) = _Year)))
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 76 | |
| 37 | |
| 31 | |
| 29 | |
| 26 |