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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
CVance
Frequent Visitor

Getting a value for a single date from X days ago

My data has gaps in the date field (non-consecutive dates).

I need a rate value for a single date from X days ago (30, 60 ...), and if the date X days ago has no value (that day is missing in the data table), then I need to back up in time until I find a value. How do I find it?

My thoughts are to create a temp table consisting of Calendar[Date], 'Rate Index'[Name], 'Rate Data'[Date], 'Rate Data'[Value], then filter the table by a timeframe (startdate: today-X-20, enddate: today-X), then use LastNonBlankValue to get the latest non-blank value.

The startdate and enddate I have as measures (windowStartDate, windowEndDate), and I have a temp table of values, but I'm having trouble getting it all together. Plus, my table has no blank rows for calendar dates with no rate data, but I think that's ok for this function.

I may be waaaay off in my thinking as I'm pretty new to DAX.

For the test data below, assume the user has selected 7/25/2010 as the date to retrieve the rate value. Since 7/25 is not a row in the table, the correct answer would be 1.5% from 7/22/2010.

Thanks in advance for any ideas!

 

NameAs of DateRate Value
Treasury 1 Month7/16/20101.20%
Treasury 1 Month7/19/20101.30%
Treasury 1 Month7/20/20101.40%
Treasury 1 Month7/22/20101.50%
Treasury 1 Month7/27/20101.60%
Treasury 1 Month7/28/20101.70%
Treasury 1 Month7/30/20101.80%
Treasury 1 Month8/3/20101.90%
1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1725687509096.png

 


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

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1725687509096.png

 


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

since these rates are immutable this can be done with a caclulated column in your Calendar table.

 

lbendlin_0-1725663447963.png

 

Thank you for this solution. It does work, but I've decided not to create a calculated column for my report.

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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