Forum Discussion

tejapowerbi123's avatar
6 years ago

How to write COALESCE with condition?

Helo Community,

I am trying to write down formula using DAX COALESCE function and I am getting below error.

“Expressions that yield variant data-type cannot be used to define calculated columns.”

How do I write below formula?

Coalsec =

 

var Good='A&I'[% Price Up or Down]>0.010000 && 'A&I'[Active / Inactive] = "Active"

var Poor='A&I'[% Price Up or Down]>=0.000000 && 'A&I'[% Price Up or Down]<=0.009999 && 'A&I'[Active / Inactive] = "Active"

 

var result=

COALESCE(Good,Poor,"No Impact")

 

return

result

 

Thanks

 

3 Replies

    • tejapowerbi123's avatar
      tejapowerbi123
      Icon for Helper V rankHelper V

      Thank you so much Amit. I am using March vesion and I am getting below error.

  • Anonymous's avatar
    Anonymous
    Not applicable

    The SQL Coalesce and IsNull functions are used to handle NULL values. During the expression evaluation process the NULL values are replaced with the user-defined value.

    The SQL Coalesce function evaluates the arguments in order and always returns first non-null value from the defined argument list.

    Syntax

    COALESCE ( expression [ 1…n ] )