cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
minbayev_b
Frequent Visitor

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors