Forum Discussion

Rapaille's avatar
Rapaille
Helper I
1 year ago
Solved

Date based on year and week

Hello all,

 

In Power BI Power Query I want to create a date table. The end day is today and my startday should be the date of the calculated Monday of the week and year columns. 

 

Can someone help me with this?

 

 

Thank you in advance for your help.

 

Kind regards,

 

Hans

 

 

  • For StartDate, go to the "Add Column" tab and select "Custom Column" :

     

    Date.AddDays(Date.FromText(Text.From([Year]) & "-01-01"), (([Week] - 1) * 7) - Date.DayOfWeek(Date.FromText(Text.From([Year]) & "-01-01"))

     

     

    and for the Enddate :

     

    DateTime.Date(DateTime.LocalNow())

    If you can provide some data, it will be helpful 🙂

     

     

2 Replies

  • For StartDate, go to the "Add Column" tab and select "Custom Column" :

     

    Date.AddDays(Date.FromText(Text.From([Year]) & "-01-01"), (([Week] - 1) * 7) - Date.DayOfWeek(Date.FromText(Text.From([Year]) & "-01-01"))

     

     

    and for the Enddate :

     

    DateTime.Date(DateTime.LocalNow())

    If you can provide some data, it will be helpful 🙂

     

     

  • Hi AmiraBedh,

     

    Thank you for your help. That was exactly where I was looking form

     

    Kind regards,

     

    Hans