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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Fill in blank value with most resent value and reset at the new year.

I am looking to fill in blank values with the most recent values that resets to 0 after the new year. This worked last year because the data only had 2023 in it. Now the data goes until the end of 2024... You can see that in 2023 the YTD Count works correctly, taking the values found and missing in the Lookup row and filling them in. All looks well in this example because there just so happens to be a value for YearMonth 2024-1 in Lookup (2). In the case where that value is subsequently 0 my dilemna arises. it will pull the most recent value from 2023-9 of 15. I want that to reset at 2024-1 to be 0. 

 

The formula i have so far (works for a single year but doesnt work in the case of more than 1 year): 

YTD_Count =
IF('Whs Part Month'[Lookup] = BLANK(),
    VAR _whspart = 'Whs Part Month'[Whs and Part]
    VAR _date = 'Whs Part Month'[Date]
    VAR _filter = FILTER('Whs Part Month', 'Whs Part Month'[Whs and Part] = _whspart && 'Whs Part Month'[Date] <= _date && 'Whs Part Month'[Lookup] <> BLANK() )
    VAR _maxdate = MAXX(_filter, 'Whs Part Month'[Date])
    RETURN
    MAXX(FILTER(_filter, [Date] = _maxdate && [Whs and Part] = _whspart), [Lookup]), 'Whs Part Month'[Lookup])
 
 
 
I think the problem is the MAXX function not enabling the anual reset... help appreciated! 
 
pbi.png

 

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Anonymous 

Use this calculated column:

YTD Count = 
  VAR _whspart = 'Whs Part Month'[Whs and Part]
  VAR _date = 'Whs Part Month'[Date]
  VAR _year = YEAR('Whs Part Month'[Date])
  VAR _T1 = 
      FILTER(
             'Whs Part Month',
             'Whs Part Month'[Whs and Part] = _whspart && 
             'Whs Part Month'[Date] <= _date &&
             'Whs Part Month'[Lookup] <> BLANK() &&
             YEAR( 'Whs Part Month'[Date] ) = _year

        )
  VAR _DateLast = MAXX( _T1 ,  'Whs Part Month'[Date] )
  VAR _result = MAXX(  FILTER( _T1  , 'Whs Part Month'[Date] =  _DateLast ) , 'Whs Part Month'[Lookup] )    
    RETURN
        COALESCE(_result,0)   

Fowmy_0-1705687651250.png


Scenario with no value to start 2024.

Fowmy_1-1705687813777.png

 

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

1 REPLY 1
Fowmy
Super User
Super User

@Anonymous 

Use this calculated column:

YTD Count = 
  VAR _whspart = 'Whs Part Month'[Whs and Part]
  VAR _date = 'Whs Part Month'[Date]
  VAR _year = YEAR('Whs Part Month'[Date])
  VAR _T1 = 
      FILTER(
             'Whs Part Month',
             'Whs Part Month'[Whs and Part] = _whspart && 
             'Whs Part Month'[Date] <= _date &&
             'Whs Part Month'[Lookup] <> BLANK() &&
             YEAR( 'Whs Part Month'[Date] ) = _year

        )
  VAR _DateLast = MAXX( _T1 ,  'Whs Part Month'[Date] )
  VAR _result = MAXX(  FILTER( _T1  , 'Whs Part Month'[Date] =  _DateLast ) , 'Whs Part Month'[Lookup] )    
    RETURN
        COALESCE(_result,0)   

Fowmy_0-1705687651250.png


Scenario with no value to start 2024.

Fowmy_1-1705687813777.png

 

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.