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
mb0307
Responsive Resident
Responsive Resident

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
Responsive Resident
Responsive Resident

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
Responsive Resident
Responsive Resident

Found a solution on Desktop forum:

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

mahoneypat
Employee
Employee

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
Community Champion
Community Champion

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

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

mb0307
Responsive Resident
Responsive Resident

@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
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.

Top Solution Authors
Top Kudoed Authors