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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Date table addition

Hi Guys, 

 

I have a date table and i want to add a combination of the weeknumber - first day of that week - last day of that week. 

 

I have the columns Date and Weeknum, so this is enough to create the combination above. Someone any idea how to fix this? 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Try

Week Start date = DATEADD('Date'[Date],-1*WEEKDAY('Date'[Date])+1,DAY)
Week End date = DATEADD('Date'[Date],7-1*WEEKDAY('Date'[Date]),DAY)
Week of = format(DATEADD('Date'[Date],-1*WEEKDAY('Date'[Date])+1,DAY),"mm/dd/yy"  & " - " & format(DATEADD('Date'[Date],7-1*WEEKDAY('Date'[Date]),DAY),"mm/dd/yy"))

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

View solution in original post

4 REPLIES 4
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please check the formula below.

Column = 
var first = CALCULATE(MIN('Date'[Date]),FILTER('Date','Date'[weeknum]=EARLIER('Date'[weeknum])))
var last = CALCULATE(MAX('Date'[Date]),FILTER('Date','Date'[weeknum]=EARLIER('Date'[weeknum])))
return
"week"&'Date'[weeknum]&"-"&first&"-"&last

Result would be shown as below.

 1.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

Try

Week Start date = DATEADD('Date'[Date],-1*WEEKDAY('Date'[Date])+1,DAY)
Week End date = DATEADD('Date'[Date],7-1*WEEKDAY('Date'[Date]),DAY)
Week of = format(DATEADD('Date'[Date],-1*WEEKDAY('Date'[Date])+1,DAY),"mm/dd/yy"  & " - " & format(DATEADD('Date'[Date],7-1*WEEKDAY('Date'[Date]),DAY),"mm/dd/yy"))

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

az38
Community Champion
Community Champion

Hi @Anonymous 

you can use the next statements for calculation:

FirstDayOfWeek = 'Date'[Date] - WEEKDAY('Date'[Date],2)+1

and

LastDayOfWeek = 'Date'[Date] - WEEKDAY('Date'[Date],2)+7

 

then use CONCATENATE function https://docs.microsoft.com/en-us/dax/concatenate-function-dax to get any combination you wish in desired format

 

do not hesitate to give a kudo to useful posts and mark solutions as solution

LinkedIn


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

What i want: “week1 - 1/1/2020 - 1/7/2020” do i achieve this with your solution?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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