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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Is it possible to convert IF + Isblank code to COALESCE

 

 

 

 

VAR result =
    IF (
        ISBLANK ( [col1] ),
        BLANK (),
        IF (
            ISBLANK ( [col2] ),
            BLANK (),
            ( DIVIDE ( [col1], [col2] ) - 1 )
        )
    )
RETURN
    result

 

 

 

 Does anyone know how to convert code using Coalesce ?

Thanks for your support.

1 ACCEPTED SOLUTION
Adamboer
Responsive Resident
Responsive Resident

Here's an example of how the code can be converted using Coalesce:

VAR result = DIVIDE ( COALESCE ( [col1], BLANK() ), COALESCE ( [col2], BLANK() ) ) - 1 RETURN result

Coalesce is a function that returns the first non-blank value in a list of expressions. In this case, it's being used to replace the ISBLANK function. The result will be the same as the original code but using a different function.

View solution in original post

1 REPLY 1
Adamboer
Responsive Resident
Responsive Resident

Here's an example of how the code can be converted using Coalesce:

VAR result = DIVIDE ( COALESCE ( [col1], BLANK() ), COALESCE ( [col2], BLANK() ) ) - 1 RETURN result

Coalesce is a function that returns the first non-blank value in a list of expressions. In this case, it's being used to replace the ISBLANK function. The result will be the same as the original code but using a different function.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors