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
F_mmb
Frequent Visitor

Replce blank with last value in dax

I have a table that includes order details, with columns for order year and category as shown in the sample below:

 

IdcategoryYear
1x2020
2x2020
3y2020
4y2020
5y2020
8z2020

 

I want to count the cumulative number of orders I have per year and category. So, I created the following measures.

 

IDCount = COUNT(Fact[Id])
CumulativeIDCount =
CALCULATE(
SUMX(
FILTER(
ALL(Fact),
Fact[Year] <= MAX(Fact[Year]) &&
Fact[category] = SELECTEDVALUE(Fact[category])
),
[IDCount]
)
)

 

Then, I used a matrix to present the results, and it is quite what I want. However, for empty values, I want to replace the value with the last value before it.

 

the result:

cetegory20142015201620172018201920202021202220232024
x        1  
y34849046704284795744734516
z6  7       
f  13     14  
t1819  2024 253233 

 

the result I expected: 

cetegory20142015201620172018201920202021202220232024
x        111
y34849046704284795744734516
z66677777777
f  131313131313141414
t1819191920242425323333

 

I need your help to modify the current DAX measure to handle blank values as fill down approach.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from @lbendlin , please allow me to provide another insight: 

Hi  @F_mmb ,

 

Here are the steps you can follow:

1. Create measure.

Test =
var _year=
MAXX(
    FILTER(ALL('Table'),
    'Table'[Category]=MAX('Table'[Category])&&
    [CumulativeIDCount]<>BLANK()&&'Table'[Year]<MAX('Table'[Year])),[Year])
return
IF(
    [CumulativeIDCount]=BLANK(),
SUMX(
    FILTER(ALL('Table'),
    'Table'[Category]=MAX('Table'[Category])
    &&
   'Table'[Year]=_year&&[CumulativeIDCount]<>BLANK()
    ),[CumulativeIDCount]),
    [CumulativeIDCount])

2. Result:

vyangliumsft_0-1719391311364.png

 

 

Best Regards,

Liu Yang

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

3 REPLIES 3
Anonymous
Not applicable

Thanks for the reply from @lbendlin , please allow me to provide another insight: 

Hi  @F_mmb ,

 

Here are the steps you can follow:

1. Create measure.

Test =
var _year=
MAXX(
    FILTER(ALL('Table'),
    'Table'[Category]=MAX('Table'[Category])&&
    [CumulativeIDCount]<>BLANK()&&'Table'[Year]<MAX('Table'[Year])),[Year])
return
IF(
    [CumulativeIDCount]=BLANK(),
SUMX(
    FILTER(ALL('Table'),
    'Table'[Category]=MAX('Table'[Category])
    &&
   'Table'[Year]=_year&&[CumulativeIDCount]<>BLANK()
    ),[CumulativeIDCount]),
    [CumulativeIDCount])

2. Result:

vyangliumsft_0-1719391311364.png

 

 

Best Regards,

Liu Yang

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

Thank you. The issue is that IDCount is not a column; it is a measure, as I mentioned in the post.

lbendlin
Super User
Super User

However, for empty values, I want to replace the value with the last value before it

To report on things that are not there you need to use disconnected tables and/or crossjoins

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.