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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Kudoed Authors