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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
kkanukurthi
Helper III
Helper III

Find last Saturday of previous month and last friday of current month end in given Date table

 

Hi @Anonymous , 

 
It works perfect for me. Above solution is for dates between CALENDAR("4/1/2024", "8/31/2024"). I mean it is comparing Month(Today()). 
 
Can you please help me with Dax code for dates between 01/01/2023 to 31/12/2025. I need for past and future dates please.
What is the slight modification that I need to do in Dax code? 

Thanks in Advance

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @kkanukurthi ,

Based on my testing, please try the following methods:

1.Create the simple table.

vjiewumsft_0-1718010015988.png

2.Create the new column to find the last Friday current month.

last friday current month = 
CALCULATE(
    MAX('Table'[Date]), 
    FILTER(
        'Table', 
        MONTH('Table'[Date]) = 
        MONTH(EARLIER('Table'[Date])) 
        && YEAR('Table'[Date]) = YEAR(EARLIER('Table'[Date])) &&
        'Table'[weekday] = 5
    )
)

3.Create the new column to find the last Saturday previous month.

last saturday previous month = 
var last_mon = 'Table'[Date]
var last_year = CALCULATE(
    MAX('Table'[Date]), 
    FILTER(
        'Table', 
        MONTH('Table'[Date]) = 
        MONTH(last_mon) - 1
        && YEAR('Table'[Date]) = YEAR(last_mon) &&
        'Table'[weekday] = 6
    )
)
var last_12 = 
CALCULATE(
    MAX('Table'[Date]), 
    FILTER(
        'Table', 
        MONTH('Table'[Date]) = 12
        && YEAR('Table'[Date]) = YEAR(last_mon) - 1 &&
        'Table'[weekday] = 6
    )
)
RETURN
IF(MONTH('Table'[Date]) = 1, last_12, last_year)

4.The result is shown below.

vjiewumsft_1-1718010033374.png

 

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @kkanukurthi ,

Based on my testing, please try the following methods:

1.Create the simple table.

vjiewumsft_0-1718010015988.png

2.Create the new column to find the last Friday current month.

last friday current month = 
CALCULATE(
    MAX('Table'[Date]), 
    FILTER(
        'Table', 
        MONTH('Table'[Date]) = 
        MONTH(EARLIER('Table'[Date])) 
        && YEAR('Table'[Date]) = YEAR(EARLIER('Table'[Date])) &&
        'Table'[weekday] = 5
    )
)

3.Create the new column to find the last Saturday previous month.

last saturday previous month = 
var last_mon = 'Table'[Date]
var last_year = CALCULATE(
    MAX('Table'[Date]), 
    FILTER(
        'Table', 
        MONTH('Table'[Date]) = 
        MONTH(last_mon) - 1
        && YEAR('Table'[Date]) = YEAR(last_mon) &&
        'Table'[weekday] = 6
    )
)
var last_12 = 
CALCULATE(
    MAX('Table'[Date]), 
    FILTER(
        'Table', 
        MONTH('Table'[Date]) = 12
        && YEAR('Table'[Date]) = YEAR(last_mon) - 1 &&
        'Table'[weekday] = 6
    )
)
RETURN
IF(MONTH('Table'[Date]) = 1, last_12, last_year)

4.The result is shown below.

vjiewumsft_1-1718010033374.png

 

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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