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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
nok
Advocate II
Advocate II

Search for the value that was at the beginning of the filtered year

Hi!

I have two tables that follow this structure:

"Main"

Entity    FileDate
AAA12/09/2025  
BBB12/03/2025

 

"Responses"

Entity  Last Response Date  Score  
AAA02/02/202415
AAA30/06/202420
AAA20/02/202550
AAA29/08/202540
BBB02/02/202332
BBB28/03/202545

 

I want to create a measure that search the Score value from "Responses" table, relating the two tables by the Entity column. But it needs to bring the score that was at the beginning of the year, that is, the score that was when the day was January 1st of the year that the user filtered (based on the "FileDate" column of the "Main" table). If there is no previous value for the filtered year, the calculation should return the most recent previous score.

Example 1: If the user filtered on today's date, 30/09/2025, the final result should be this:

Entity  Q1_Score  
AAA20
BBB32

PS: The AAA score is 20, as that was the score on 01/01/2025. Only on 20/02/2025, the score changed to 50. Therefore, the correct value to be displayed for this score is 20.

PS.2: The BBB score is 32 because, even though it is the score defined in 2023, it remained the same until it was changed in March 2025. As on 01/01/2025 it was still 32, this is the correct value.

 

Example 2: If the user filtered on the date of the 12/12/2024, the final result should be this:

Entity  Q1_Score  
AAA15
BBB32


How can I do this?

1 ACCEPTED SOLUTION
GeraldGEmerick
Super User
Super User

@nok I believe that the following should be sufficient for your use case:

Previous Score = 
VAR _Date = MAX( 'Main'[FileDate] )
VAR _PreviousDate = CALCULATE( MAX( 'Responses'[Last Response Date] ), 'Responses'[Last Response Date] < _Date )
VAR _Return = CALCULATE( MAX( 'Responses'[Score] ), 'Responses'[Last Response Date] = _PreviousDate )
RETURN _Return

View solution in original post

4 REPLIES 4
danextian
Super User
Super User

Hi @nok 

I am confused. I don't get the significance of the file date. The user selects Sept 30 which isnt in the file dates. The way I see it is you're looking for the the value of  the earliest date before the selected date. 

danextian_0-1759325500256.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ashish_Mathur
Super User
Super User

HI,

What is the use of the Main table in asnwerig your question.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
GeraldGEmerick
Super User
Super User

@nok I believe that the following should be sufficient for your use case:

Previous Score = 
VAR _Date = MAX( 'Main'[FileDate] )
VAR _PreviousDate = CALCULATE( MAX( 'Responses'[Last Response Date] ), 'Responses'[Last Response Date] < _Date )
VAR _Return = CALCULATE( MAX( 'Responses'[Score] ), 'Responses'[Last Response Date] = _PreviousDate )
RETURN _Return
lbendlin
Super User
Super User

If there is no previous value for the filtered year, the calculation should return the most recent previous score.

That means your example 2 should yield 20 for AAA, not 15.

 

Please clarify "most recent previous score".

 

lbendlin_0-1759268452216.png

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.