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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
andreas789
Frequent Visitor

Power BI Report Builder: DAX query to retrieve last week (Sunday - Saturday)

Hello, I need a DAX query, to query a power bi dataset for values in the last week and is equivalent to the following one:

 

  VAR __DS0FilterTable = 
    FILTER(
      KEEPFILTERS(VALUES('salesty'[TRANS_DATE])),
      AND(
        'salesty'[TRANS_DATE] >= DATE(2022, 1, 2),
        'salesty'[TRANS_DATE] < DATE(2022, 1, 9)
      )
    )

 

Basically, I think I need a DAX formula to get last week's values between Saturday and Saturday.

1 ACCEPTED SOLUTION
andreas789
Frequent Visitor

Thanks everybody for your suggestions.

Since the dataset was getting updated every monday, I was able to find a solution by using MAX function and subtracting the days.

View solution in original post

3 REPLIES 3
andreas789
Frequent Visitor

Thanks everybody for your suggestions.

Since the dataset was getting updated every monday, I was able to find a solution by using MAX function and subtracting the days.

ValtteriN
Community Champion
Community Champion

Hi,

You can use Weeknum to get this result. So something like this:

LastWeekT =
var weeknumLW = WEEKNUM(TODAY())-1
VAR __DS0FilterTable =
FILTER(
'LastWeek',
WEEKNUM('LastWeek'[Date])=weeknumLW
)
 
return
 
__DS0FilterTable


The default setting for WEEKNUM starts from Sunday so with this you should get last week with this dax. 

End result (visualized):
ValtteriN_0-1641809154625.png

 

Now you can just refer to this var tables columns e.g. in SUMX and you cant get the results you want. I hope this helps and if it does consider accepting this as a solution and giving the post a thumbs up!

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@andreas789 , You need these new columns in date tbale

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],1)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],1)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

then  measures
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8

 

 

Hope the same work in report builder

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.