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
PeteSil1020
Helper I
Helper I

Finding Most Recent Date based off Selected Date in Slicer

Hello,

I am really struggling with such a simple measure that I feel should not be this hard. All I am trying to do is show the most recent date that is less than or equal to the selected date. So for example my slicer has you choose the EndofMonth that you want to see. I would then expect the measure to reflect the below results give the below data. 

 

EndofMonth = 11/30/2023

 

Data:

Student 1     11/21/2023
Student 1     10/1/2023
Student 1     4/1/2023
Student 2     10/1/2023
Student 2     11/15/2023
Student 2    12/5/2023
Student 3     8/10/2023
Student 3     5/1/2023
Student 4     9/1/2023
Student 4     8/18/2023
Student 4      7/1/2023
Student 4     10/15/2023

 

Result:

Student 1      11/21/2023
Student 2      11/15/2023
Student 3      8/10/2023
Student 4     10/15/2023

 

Any help on this will be greatly appreciated.

1 ACCEPTED SOLUTION

I was actually able to solve this myself. The reason it was limiting the dates to that particular month was due to me using the same date column for the filtering. I created a new table such as Calendar = Calendar(Min('Student Data - SQL'[EndofMonth]), Max('Student Data - SQL'[EndofMonth])). I then changed the formula to point toward 'Calendar'[Date] and it worked perfectly.

View solution in original post

3 REPLIES 3
vicky_
Super User
Super User

Latest Date = CALCULATE(MAX('Table'[Column2]), 'Table'[Column2] <= DATE(2023, 11, 30))

just replace the hard-coded date with your slicer value

Unfortunately this isn't working. This is my current measure:

Students by Date =
Var CurrentDate = SELECTEDVALUE('Student Data - SQL'[EndofMonth])
RETURN
CALCULATE(
    MAX('Student Data - SQL'[MaxAsOf]),
    'Student Data - SQL'[MaxAsOf] <= CurrentDate)
 
When I do this I have the filter for EndofMonth selected to 11/30/2023. When I do this it is limiting the view to only show students that have a date within that month, instead of showing all students.
 
Result:
 
Student 1      11/21/2023
Student 2       11/15/2023

I was actually able to solve this myself. The reason it was limiting the dates to that particular month was due to me using the same date column for the filtering. I created a new table such as Calendar = Calendar(Min('Student Data - SQL'[EndofMonth]), Max('Student Data - SQL'[EndofMonth])). I then changed the formula to point toward 'Calendar'[Date] and it worked perfectly.

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.