cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kevindmonte
Helper II
Helper II

Get Week Ending Friday date when new week starts from Saturday

Hi, We have a requirement such that we need to get the Week Ending Friday date for any given date but it should be the coming Friday. and not the Friday before. What's happening now is that if I have a date of say 3rd April 2021 which is Saturday, the DAX formula is returning 2nd April 2021 as Week Ending Friday whereas I want it to return 9th April for 3rd April (which is Sat.). 

 

Below is the DAX 

Dates TEST = 
ADDCOLUMNS (
CALENDAR (DATE(2021,1,1), DATE(2021,12,31)),
"Day", FORMAT([Date], "dddd"),
"Week Ending Fri Date", [Date] + 6 -  WEEKDAY([date])

)

kevindmonte_0-1620126373699.png


can anyone please advise a solution?

 

Regards, 
KD.



 

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Community Champion
Community Champion

Hi, @kevindmonte 

I think it is easier if you create a weekend column in Power Query Editor for Friday weekenddate.

 

Please check the below picture and the M-code.

If you do not want to write M-code, you can just add weekenddate column by using UI, and just add number 6 like below.

 

= Table.AddColumn(#"Changed Type", "End of Week", each Date.EndOfWeek([Date],6), type date)

 

Picture6.png

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

daxer
Solution Sage
Solution Sage

[Dates] =
ADDCOLUMNS(
    CALENDAR(
        DATE( 2021, 1, 1 ),
        DATE( 2021, 12, 31 )
    ),
    "Day",
        FORMAT(
            [Date],
            "ddd"
        ),
    "Week Ending Friday",
        var DayNumber = WEEKDAY( [Date], 2 )
        return
            [Date]
            + ( 5 - DayNumber)
            + 7 * (DayNumber > 5)
)

 

View solution in original post

5 REPLIES 5
daxer
Solution Sage
Solution Sage

[Dates] =
ADDCOLUMNS(
    CALENDAR(
        DATE( 2021, 1, 1 ),
        DATE( 2021, 12, 31 )
    ),
    "Day",
        FORMAT(
            [Date],
            "ddd"
        ),
    "Week Ending Friday",
        var DayNumber = WEEKDAY( [Date], 2 )
        return
            [Date]
            + ( 5 - DayNumber)
            + 7 * (DayNumber > 5)
)

 

View solution in original post

Hi, many thanks for quick reply. this also worked for me. 

Jihwan_Kim
Community Champion
Community Champion

Hi, @kevindmonte 

I think it is easier if you create a weekend column in Power Query Editor for Friday weekenddate.

 

Please check the below picture and the M-code.

If you do not want to write M-code, you can just add weekenddate column by using UI, and just add number 6 like below.

 

= Table.AddColumn(#"Changed Type", "End of Week", each Date.EndOfWeek([Date],6), type date)

 

Picture6.png

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

many thanks. I will give this a go and let you know. 

amitchandak
Super User IV
Super User IV

@kevindmonte , In this blog I have given all possible 7-weekday calendars

 

Any Weekday Week - Start From Any day of Week
https://community.powerbi.com/t5/Community-Blog/Any-Weekday-Week-Decoding-Date-and-Calendar-2-5-Powe...



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Helpful resources

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

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors