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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
KristinaSp
Helper I
Helper I

Fill blank values with previous max values

Hello,

 

I have found few similar topics, but neither helped with my issue.

 

I need to write measure, which fills empty values with previous max values.

And I almost did it.  In the table below, you can see, that I managed to fill 2022-09-24 and 2022-09-24 with previous max value (on 2022-09-23), becouse 2022-09-23 have only one value (only one row per day). If there are few rows (like in 2023-09-15), my measure does not work.

Any sollutions?

 

_max_value_no_blanks =

 

VAR latest_non_blank_date =

CALCULATE( MAX('Calendar'[Date]),

 FILTER(ALL('table),

 'table'[date] <=  MAX('Calendar'[Date]) &&

 'table'[value] <> 0

 ))

 

 VAR latest_non_blank_value =

 calculate( MAX('table'[value]),

 FILTER(ALL('Calendar'[Date]), 'Calendar'[Date] = latest_non_blank_date))

 

 RETURN

 

 latest_non_blank_rida

 

KristinaSp_0-1681306273153.png

KristinaSp_1-1681306656758.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @KristinaSp ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1682406621786.png

(2) We can create a measure. 

 

fill blank = 
var _a =CALCULATE(MAX('Table'[date]),FILTER(ALL('Table'),'Table'[date]<=MAX('Table'[date]) && 'Table'[value]<>BLANK()))
 var _b= CALCULATE(MAX('Table'[value]),FILTER(ALL('Table'),'Table'[date]<=_a))
 return 
 IF(MAX('Table'[value])=BLANK() && _a<>BLANK(),_b,MAX('Table'[value]))

 

(3) Then the result is as follows.

vtangjiemsft_1-1682406644314.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @KristinaSp ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1682406621786.png

(2) We can create a measure. 

 

fill blank = 
var _a =CALCULATE(MAX('Table'[date]),FILTER(ALL('Table'),'Table'[date]<=MAX('Table'[date]) && 'Table'[value]<>BLANK()))
 var _b= CALCULATE(MAX('Table'[value]),FILTER(ALL('Table'),'Table'[date]<=_a))
 return 
 IF(MAX('Table'[value])=BLANK() && _a<>BLANK(),_b,MAX('Table'[value]))

 

(3) Then the result is as follows.

vtangjiemsft_1-1682406644314.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors