Forum

Date from year &...
 
Notifications
Clear all

Date from year & week in Power Query

3 Posts
2 Users
0 Reactions
55 Views
(@vrossouw7)
Posts: 12
Eminent Member
Topic starter
 

Hi,

Hi, I have the below formula in Excel, where P2 is the Year and Q2 is the week number, of which the result is the start of the week. 

P2 = 2021

Q2 = 22

Result = 31 May 2021

 

=MAX(DATE(P2,1,1),DATE(P2,1,1)-WEEKDAY(DATE(P2,1,1),2)+(Q2-1)*7+1)+7

How can I write the query in Power Query (Power BI), to get the same result?

My query is a direct download, so I can't do this in Excel before uploading it to Power BI.

Thank you

Vicky

 
Posted : 27/05/2021 8:03 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Vicky,

You can use this formula:

=List.Max({
   #date([Year],1,1),
Date.AddDays(
   #date([Year],1,1), 
   (
   -(Date.DayOfWeek(#date([Year],1,1),Day.Monday))
   +([Week]-1)*7+7)
    )
   }
)

 

Please see file attached.

Mynda

 
Posted : 27/05/2021 8:31 pm
(@vrossouw7)
Posts: 12
Eminent Member
Topic starter
 

Sooo Amazing, thank you. 

 
Posted : 30/05/2021 12:19 am
Share: