Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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 | Value | Expected o/p |
29/12/2023 | 800 | |
15/02/2024 | 50 | |
28/04/2024 | 40 | |
08/04/2024 | 80 | |
07/01/2025 | 90 | 800 |
08/01/2025 | 50 | 800 |
13/01/2025 | 900 | 800 |
10/02/2025 | 60 | 50 |
28/02/2025 | 80 | 50 |
17/03/2025 | 150 | 50 |
15/04/2025 | 100 | 80 |
Solved! Go to Solution.
SAMEPERIODLASTYEAR for a single value is ambiguous. Please be more specific. Do you mean "prior year" ?
or like this
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.?
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
9 | |
8 | |
8 | |
8 |
User | Count |
---|---|
13 | |
12 | |
11 | |
10 | |
9 |