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
nicolasvc
Helper III
Helper III

Fill blank values

I have a table that contains a column with integer values ​​and other empty ones (Blank), but I would like to be able to fill the empty values ​​with -1 when there is a value greater than 0 in a the product A, and 0 in case it is 0, such as the second table shows:

 

StoreProductValue
1A1
1B 
1C 
2A2
2B 
2C 
3A0
3B 
3C 

 

StoreProductValue
1A1
1B-1
1C-1
2A2
2B-1
2C-1
3A0
3B0
3C0

Is it possible to occupy a conditional within the EARLIER function, or is there another way to do it in DAX?

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @nicolasvc 

 

You can try creating new calculated columns and measures to fill in blank values.

  1. Calculated column

 

New value =
IF (
    [Value] <> BLANK (),
    [Value],
    IF (
        CALCULATE (
            MIN ( 'Table'[Value] ),
            FILTER ( 'Table', [Store] = EARLIER ( 'Table'[Store] ) && [Product] = "A" )
        ) > 0,
        -1,
        IF (
            CALCULATE (
                MIN ( 'Table'[Value] ),
                FILTER ( 'Table', [Store] = EARLIER ( 'Table'[Store] ) && [Product] = "A" )
            ) = 0,
            0
        )
    )
)

 

vzhangti_0-1637198406057.jpeg

 

   2. Measure

 

Measure =
IF (
    MAX ( 'Table'[Value] ) <> BLANK (),
    MAX ( 'Table'[Value] ),
    IF (
        CALCULATE (
            MAX ( 'Table'[Value] ),
            FILTER ( ALL ( 'Table' ), [Store] = MAX ( 'Table'[Store] ) && [Product] = "A" )
        ) > 0,
        -1,
        IF (
            CALCULATE (
                MAX ( 'Table'[Value] ),
                FILTER ( ALL ( 'Table' ), [Store] = MAX ( 'Table'[Store] ) && [Product] = "A" )
            ) = 0,
            0
        )
    )
)

 

vzhangti_1-1637198455702.png

 

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @nicolasvc 

 

You can try creating new calculated columns and measures to fill in blank values.

  1. Calculated column

 

New value =
IF (
    [Value] <> BLANK (),
    [Value],
    IF (
        CALCULATE (
            MIN ( 'Table'[Value] ),
            FILTER ( 'Table', [Store] = EARLIER ( 'Table'[Store] ) && [Product] = "A" )
        ) > 0,
        -1,
        IF (
            CALCULATE (
                MIN ( 'Table'[Value] ),
                FILTER ( 'Table', [Store] = EARLIER ( 'Table'[Store] ) && [Product] = "A" )
            ) = 0,
            0
        )
    )
)

 

vzhangti_0-1637198406057.jpeg

 

   2. Measure

 

Measure =
IF (
    MAX ( 'Table'[Value] ) <> BLANK (),
    MAX ( 'Table'[Value] ),
    IF (
        CALCULATE (
            MAX ( 'Table'[Value] ),
            FILTER ( ALL ( 'Table' ), [Store] = MAX ( 'Table'[Store] ) && [Product] = "A" )
        ) > 0,
        -1,
        IF (
            CALCULATE (
                MAX ( 'Table'[Value] ),
                FILTER ( ALL ( 'Table' ), [Store] = MAX ( 'Table'[Store] ) && [Product] = "A" )
            ) = 0,
            0
        )
    )
)

 

vzhangti_1-1637198455702.png

 

 

Best Regards,

Community Support Team _Charlotte

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

Stachu
Community Champion
Community Champion

Is Value a regular column/calculated column in the model table or a measure in the visual?
If it's a regular column then it cannot be modified with DAX, but it should be possible with M. Alternatively an additional calculated column can be added that will have the blanks filled.

If it's a calculated column/measure then what's its syntax?



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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