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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
akhaliq7
Post Prodigy
Post Prodigy

Require a scalar value based on the latest week number

I have a income field that needs to be returned (scalar value) filtered on the latest week. E.G. table1[income], table 2[week number]. 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @akhaliq7 

I suppose table2 filters table1. Then

Last Week Income =
VAR LastDateWithIncome =
    CALCULATE ( MAX ( table1[Date] ), REMOVEFILTERS () )
VAR LastWeekWithIncome =
    WEEKNUM ( LastDateWithIncome, 2 )
RETURN
    CALCULATE ( SUM ( table1[income] ), table2[week number] = LastWeekWithIncome )

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @akhaliq7 

I suppose table2 filters table1. Then

Last Week Income =
VAR LastDateWithIncome =
    CALCULATE ( MAX ( table1[Date] ), REMOVEFILTERS () )
VAR LastWeekWithIncome =
    WEEKNUM ( LastDateWithIncome, 2 )
RETURN
    CALCULATE ( SUM ( table1[income] ), table2[week number] = LastWeekWithIncome )
amitchandak
Super User
Super User

@akhaliq7 , week based today

 

This Week today =
var _st = today() +-1*WEEKDAY(today(),2)+1
var _end =today()+ 7-1*WEEKDAY(today(),2)
return
CALCULATE(SUM(Sales[Sales Amount]),filter('Date','Date'[Date]>= _st && 'Date'[Date]<=_end ))

//use all('Date') if need in filter

 

 

else you need columns and measures

 

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

 

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

 

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

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 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.