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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Antmkjr
Post Patron
Post Patron

Dynamically find the nearest non-blank value in Sameperiod last year

I have data as shown below:

Expected o/p is nearest non-blank value in the same period last year. If for Sameperiod last year Value is not available,  returns a blank, it should search both before and after that month (expanding outward month-by-month) for until a closest non-blank is found

Date ValueExpected o/p
29/12/2023800 
15/02/202450 
28/04/202440 
08/04/202480 
07/01/202590800
08/01/202550800
13/01/2025900800
10/02/20256050
28/02/20258050
17/03/202515050
15/04/202510080
1 ACCEPTED SOLUTION

5 REPLIES 5
lbendlin
Super User
Super User

SAMEPERIODLASTYEAR for a single value is ambiguous. Please be more specific. Do you mean "prior year" ?

 

lbendlin_0-1744748173874.png

or like this

lbendlin_2-1744748709304.png

 

 

Spot On! Just that total is incorrect.

Which one is spot on? For the total to be correct you can wrap the code in an aggregation.

First one, but is it not already wrapped in aggregation.?

lbendlin_0-1744908439967.png

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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