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
robertpayne21
Frequent Visitor

Return prior value if no value exists for current Month/Year

Hi,  I'm having trouble with some dax.    This is working as expected for a month with values and returning the prior date.  If the current Month/Year does not have a value, it will return the prior month/year.   What I am having trouble with is returning the value for that period.  For example, May 2023 has no value but we can see that April 2023 has a value.  I would like to display the April 2023 value or the previous value until there is a value with a date that is >= selected date.

 

_TEST1 Dated Avg Labor Rate =

var _minsel = MAX(DimDate[Date])
var _selected = LASTNONBLANK(FILTER(ALL(DimDate[Date]), DimDate[Date]<=_minsel),[Hmmm])
Return _selected
 
Not seeing April value forward.
robertpayne21_1-1689635899691.png

 

 

April Value

robertpayne21_2-1689635945973.png

 

 
 
For reference:
Hmmm = sum(VW_SPECIAL_CUSTOMER_LABOR_RATE_UNIONED_VIEWS[LABOR_RATE])
 
 
 

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can modify your code which returns the date to use LASTNONBLANKVALUE instead of LASTNONBLANK.

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

You can modify your code which returns the date to use LASTNONBLANKVALUE instead of LASTNONBLANK.

This did work with one caveat.  On the report, the date filter needs to use the full date key, for example dimdate[date] vs dimdate[monthyear].  Thank You.

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.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.