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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Matej
Helper I
Helper I

Value returned based on specific time requirement

Hello all, 

I'm trying to figure out an issues in my report. 

 

I have a list of items with cost that is being changed at random intervals (my current dataset includes data from 1/1/22 - 31/1/23). I have managed to write some measured to get first and last cost based on filter context: 

 

_lastOldIDC =
VAR tbl = VALUES('IDCs')
VAR max_date = MAXX('IDCs', [Maximum of Date])
VAR result =  MINX(FILTER(tbl, [Maximum of Date] = max_date), [Old Value])
RETURN
    result
 
_firstOldIDC =
VAR tbl = VALUES('IDCs')
VAR min_date = MINX('IDCs', [Maximum of Date])
VAR result =  MINX(FILTER(tbl, [Maximum of Date] = min_date), [Old Value])
RETURN
    result
 
snip.png
 
These two work great but now I need a similiar measure that will only return a value (cost change) that represents the last value in the column before 10/11/2022. In the example based on the screenshot the value returned would be £2.43 as a last value in the column before the treshold (10/11/22). My measures can filter out other values and dates if I use a slicer but that only captures defined space of time and not the last cost change done prior to 10/11/2022. 
Any help here would be massively appreaciated. 
1 ACCEPTED SOLUTION
sebastiandyrby
Resolver I
Resolver I

Hi

This could be done like this - is that what you're looking for?

sebastiandyrby_0-1675946385713.png

This returns the following with my dataset-copy:

sebastiandyrby_1-1675946424489.png

 

Best regards

View solution in original post

2 REPLIES 2
sebastiandyrby
Resolver I
Resolver I

Hi

This could be done like this - is that what you're looking for?

sebastiandyrby_0-1675946385713.png

This returns the following with my dataset-copy:

sebastiandyrby_1-1675946424489.png

 

Best regards

This is literally what I've been looking for. Many thanks for the help!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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