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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Anonymous
Not applicable

calculated Column Flag of 1 to show previous 5 weeks based on current week and date

Hi Experts

 

Need a calculated column Flag to show 1 - where the date is in the previous 5 Weeks based on todays date and week no. The following is a image of my Table where is need to add the Previous 5 Weeks flag

 

BlueWhite111_0-1697649584194.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , In case nothing is selected

 

This Week Today =
var _min1 = today() -WEEKDAY(today() ,2) +1 //Monday week start

var _min = _min1 - 28
var _max = _min1 +6
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

if you need based on selection

 

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max1 = maxx(allselected(Date1),Date1[Date])

var _min1 = _max1 -WEEKDAY(_max1 ,2) +1 //Monday week start

var _min = _min1 - 28
var _max = _min1 +6


return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

https://medium.com/chandakamit/cheat-sheet-power-bi-time-intelligence-formulas-using-today-654f26e27304

 

Need of an Independent/disconnected Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , In case nothing is selected

 

This Week Today =
var _min1 = today() -WEEKDAY(today() ,2) +1 //Monday week start

var _min = _min1 - 28
var _max = _min1 +6
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

if you need based on selection

 

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max1 = maxx(allselected(Date1),Date1[Date])

var _min1 = _max1 -WEEKDAY(_max1 ,2) +1 //Monday week start

var _min = _min1 - 28
var _max = _min1 +6


return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

https://medium.com/chandakamit/cheat-sheet-power-bi-time-intelligence-formulas-using-today-654f26e27304

 

Need of an Independent/disconnected Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi Amit

 

Are the above measures calculated columns measures and what does not refer too in the first measure

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors