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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
amty63
Helper III
Helper III

Display data for Monday every week.

Requirement is to display data only for Monday for entire week. Next week, it should again reflect values for Monday this week only.

for example : Today is 12th May, Wednesday but report should reflect data for 10th May and if Today is 6th May, it should reflect data for 03th May. 

I hope requirement is clear.

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @amty63 ,

 

Create 2 columns as below:

Weeknum = WEEKNUM('Table'[Date],2)
First Monday = 
var _mindate=CALCULATE(MIN('Table'[Date]),FILTER('Table','Table'[Weeknum]=EARLIER('Table'[Weeknum])))
var _weekday=WEEKDAY(_mindate,2)
Return
IF(_weekday<>1,DATE(YEAR(_mindate)-1,12,31-(_weekday-1)+1),_mindate)

And you will see:

v-kelly-msft_0-1620973356413.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

View solution in original post

5 REPLIES 5
v-kelly-msft
Community Support
Community Support

Hi @amty63 ,

 

Create 2 columns as below:

Weeknum = WEEKNUM('Table'[Date],2)
First Monday = 
var _mindate=CALCULATE(MIN('Table'[Date]),FILTER('Table','Table'[Weeknum]=EARLIER('Table'[Weeknum])))
var _weekday=WEEKDAY(_mindate,2)
Return
IF(_weekday<>1,DATE(YEAR(_mindate)-1,12,31-(_weekday-1)+1),_mindate)

And you will see:

v-kelly-msft_0-1620973356413.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

This solution is flawed.  It only works for 1 year because the Weeknum column starts repeating unless you continue to add the year into the week number.  Such as 1-52 then 53- 104 as the next week.  The solution I used is to have a Week Number and Year to do the filter. 

 

Year-Week = YEAR([Date]) & FORMAT(WEEKNUM([Date], 21), "-\W00"
 
This creates Year-Week "2023-W39".  Then when the first monday is found it is found on the specific week of that specific year.  The original formula here was always using the first years week number even when it was 5 years later.
 
 
HarishKM
Impactful Individual
Impactful Individual

@amty63  Hey , 

You can create a cal. coloumn for week .
Week = weeknum(date[date],2)

2 is week starts from monday 

Jihwan_Kim
Super User
Super User

Hi, @amty63 

Please check the below picture and a sample pbix file's link down below.

I tried to create a sample pbix file based on the explanation.

 

Picture3.png

 

Sales Total Only reflects Monday =
CALCULATE (
[Sales Total],
FILTER (
ALL ( Dates ),
Dates[Week & Year] = MAX ( Dates[Week & Year] )
&& Dates[Day of Week] = 0
)
)
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

amitchandak
Super User
Super User

@amty63 , One way is to create a column in date table and default on that

 

Date Type =
var _1 = today() +-1*WEEKDAY(today() ,2)+1
return
SWITCH(TRUE(),'Date'[Date]=_1,"Last Monday"
,'Date'[Date]&"")

 

or create a measure like 

 

measure =

var _min = minx(allselected('Date1'), Date1[Date])
var _max = today() +-1*WEEKDAY(today() ,2)+1
return
calculate(Sum('Table'[Value]), filter('Date', 'Date'[Date] <=_max && 'Date'[Date] >=_min ))

 

 

Refer for Default Date Today/ This Month / This Year: https://www.youtube.com/watch?v=hfn05preQYA&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=35

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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