Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Rabi
Resolver I
Resolver I

Getting Second latest date from list of Friday dates

Hi Everyone, 

I am trying to get the second latest Friday date; I tried applying TOP N filter too but it didn't work. Please help me with this. I have a column with a list of Friday Dates.

Rabi_0-1694733263215.png

 

Regards,

Rabi

 

4 ACCEPTED SOLUTIONS

Hi @Rabi 

If you already have Date / Calendar table, adjust accordingly TOPN and FILTER part.

I created calculated column to check if 'Date'[Date] is expected value as you have.

My timezone is Europe (GMT+) - this is important as today is Friday and your time zone could be different so output could be different. 

Did I answer correctly? Kudos appreciate / accept solution.

SecondLastMonday =
    MINX (
        TOPN (
            2,
            FILTER (
                ADDCOLUMNS (
                    CALENDAR ( DATE ( 2023, 1, 1 ), DATE ( 2023, 12, 31 ) ),
                    "Year", YEAR ( [Date] ),
                    "Month", MONTH ( [DATE] ),
                    --type 2 means first day of week is Monday
                    "DayInWeekName", FORMAT ( [Date], "dddd" )
                ),
                [Date] <= TODAY ()
                    && [DayInWeekName] = "Friday"
            ),
            [Date], DESC
        ),
        [Date]
    )
 
Cal column
CheckSecLastFriday = IF('Date'[SecondLastMonday]='Date'[Date],TRUE,FALSE)
Ouput
some_bih_0-1694758891056.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






View solution in original post

parry2k
Super User
Super User

@Rabi I just saw this post, although you already have a solution but for last year friday, it need tweaking because the logic will fail on leap year.

 

SameDayLastYear_Friday =
VAR __LastYear =
DATE(YEAR('Date'[SecondLastFriday])-1,MONTH('Date'[SecondLastFriday]),DAY('Date'[SecondLastFriday]))
VAR __WeekDayOffset = 6 - WEEKDAY ( __LastYear, 1 )
RETURN
__LastYear + __WeekDayOffset


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

parry2k
Super User
Super User

@Rabi you can

2nd Last Friday From Today = 
VAR __Today = TODAY () 
VAR __TodayWeekDay = WEEKDAY ( __Today, 1 )
VAR __OffSet = IF ( __TodayWeekDay >= 6, __TodayWeekDay - 6, __TodayWeekDay + 1 ) + 7
RETURN  __Today - __OffSet

also use this expression to get the 2nd last Friday without iterating over date table:

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

parry2k
Super User
Super User

@Rabi if you want most recent Friday from today then use this:

 

2nd Last Friday From Today = 
VAR __Today = TODAY () 
VAR __TodayWeekDay = WEEKDAY ( __Today, 1 )
VAR __OffSet = IF ( __TodayWeekDay >= 6, __TodayWeekDay - 6, __TodayWeekDay + 1 ) 
RETURN  __Today - __OffSet


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

10 REPLIES 10
parry2k
Super User
Super User

@Rabi if you want most recent Friday from today then use this:

 

2nd Last Friday From Today = 
VAR __Today = TODAY () 
VAR __TodayWeekDay = WEEKDAY ( __Today, 1 )
VAR __OffSet = IF ( __TodayWeekDay >= 6, __TodayWeekDay - 6, __TodayWeekDay + 1 ) 
RETURN  __Today - __OffSet


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Rabi you can

2nd Last Friday From Today = 
VAR __Today = TODAY () 
VAR __TodayWeekDay = WEEKDAY ( __Today, 1 )
VAR __OffSet = IF ( __TodayWeekDay >= 6, __TodayWeekDay - 6, __TodayWeekDay + 1 ) + 7
RETURN  __Today - __OffSet

also use this expression to get the 2nd last Friday without iterating over date table:

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Rabi I just saw this post, although you already have a solution but for last year friday, it need tweaking because the logic will fail on leap year.

 

SameDayLastYear_Friday =
VAR __LastYear =
DATE(YEAR('Date'[SecondLastFriday])-1,MONTH('Date'[SecondLastFriday]),DAY('Date'[SecondLastFriday]))
VAR __WeekDayOffset = 6 - WEEKDAY ( __LastYear, 1 )
RETURN
__LastYear + __WeekDayOffset


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Rabi
Resolver I
Resolver I

@some_bih absolute Genius.

 

some_bih
Super User
Super User

Hi @Rabi "second latest Friday date" on 15.09.2023 is what date? I am aksing as today is 15.09.2023 and depending when you answer "second latest Friday date" will be another date.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Hi @some_bih 

Current friday is 15/09/2023 but I want to filter my data with last week's friday date which is 08/09/2023

Thanks !!

 

 

Hi @Rabi 

If you already have Date / Calendar table, adjust accordingly TOPN and FILTER part.

I created calculated column to check if 'Date'[Date] is expected value as you have.

My timezone is Europe (GMT+) - this is important as today is Friday and your time zone could be different so output could be different. 

Did I answer correctly? Kudos appreciate / accept solution.

SecondLastMonday =
    MINX (
        TOPN (
            2,
            FILTER (
                ADDCOLUMNS (
                    CALENDAR ( DATE ( 2023, 1, 1 ), DATE ( 2023, 12, 31 ) ),
                    "Year", YEAR ( [Date] ),
                    "Month", MONTH ( [DATE] ),
                    --type 2 means first day of week is Monday
                    "DayInWeekName", FORMAT ( [Date], "dddd" )
                ),
                [Date] <= TODAY ()
                    && [DayInWeekName] = "Friday"
            ),
            [Date], DESC
        ),
        [Date]
    )
 
Cal column
CheckSecLastFriday = IF('Date'[SecondLastMonday]='Date'[Date],TRUE,FALSE)
Ouput
some_bih_0-1694758891056.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






@parry2k @some_bih 

Hi Guys, 

The DAX above is still giving me date 08/09/2023, but for this week the Friday should be 15/09/2023 as it is the last weeks friday date.

 

Regards,

Rabi 

Hi @some_bih 

 

can you also help me with getting a year date from last week's Friday date for instance, last week Friday date was 08/09/2023 its a year equivalent would be 08/09/2022

 

thanks for help !!

Hi @Rabi 

For Friday / Monday option, just adjust part

&& [DayInWeekName] = "Friday" to day you wish, like "Monday"
In my post above name is SecondLastMonday but pat [DayInWeekName] = "Friday"  - typo
 
For SameDayLastYear_Friday create calculated column (keep in mind that I renamed origanal SecondLastMonday to SecondLastFriday as it was typo)
SameDayLastYear_Friday =
VAR __second_last_Monday_last_year=DATE(YEAR('Date'[SecondLastFriday])-1,MONTH('Date'[SecondLastFriday]),DAY('Date'[SecondLastFriday])+1)
RETURN
__second_last_Monday_last_year




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.