The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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.?
User | Count |
---|---|
13 | |
8 | |
8 | |
7 | |
5 |
User | Count |
---|---|
21 | |
15 | |
15 | |
10 | |
7 |