cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mb0307
Post Patron
Post Patron

Last Friday date

Hi,

 

How can I get last Friday date in a Custom Column of Power Query please?

 

Today is 28/07/2021 so last Friday date was 23/07/2021.

 

Thanks

1 ACCEPTED SOLUTION
mb0307
Post Patron
Post Patron

Found a solution on Desktop forum:

Date.AddDays(Date.From(DateTime.LocalNow()),-Date.DayOfWeek(Date.From(DateTime.LocalNow()),5))

View solution in original post

5 REPLIES 5
mb0307
Post Patron
Post Patron

Found a solution on Desktop forum:

Date.AddDays(Date.From(DateTime.LocalNow()),-Date.DayOfWeek(Date.From(DateTime.LocalNow()),5))

View solution in original post

mahoneypat
Super User IV
Super User IV

Here is one way to do it in a custom column.

 

= if Date.DayOfWeek([Date]) >= 5 then Date.AddDays(Date.StartOfWeek([Date]), 5) else Date.AddDays(Date.StartOfWeek([Date]), -2)

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


CNENFRNL
Super User III
Super User III

= Date.StartOfWeek(Date.From(DateTime.LocalNow())) - #duration(2,0,0,0)

@CNENFRNL  thanks but not what I wanted.

 

This is giving me date of 2 days ago i.e. 24/07/2021 which was Saturday.  Can it be dynamic to calculate from any date what was last Friday date? 


Thanks 

And here is another way.

 

= List.Max(List.Select(List.Dates(Date.AddDays([Date], -6),7,#duration(1,0,0,0)), each Date.DayOfWeek(_) = 5))

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Kudoed Authors