daniness
daniness

Reputation: 383

Reading derived column expression

I am in need of assistance reading this confusing derived column expression which contains multiple Boolean expressions.

I've tried reading it multiple ways, but not sure which one is correct.

ISNULL(ContractNumber) ? (ISNULL(PaidLossAmount) 
&& ISNULL(CaseReserveAmount)) ? NULL(DT_CY) : 
(ISNULL(PaidLossAmount) ? 0 : PaidLossAmount) + (ISNULL(CaseReserveAmount) 
? 0 : CaseReserveAmount) : PaidLossAmount

Could someone please advise on how this expression should be read? Thanks for your advice!

Upvotes: 2

Views: 30

Answers (1)

KeithL
KeithL

Reputation: 5594

This is a nested if then else in the format of [Logical test] ? [Do this if true] : [Do this if false]

This is the formatted version.

ISNULL(ContractNumber) 
     ?(ISNULL(PaidLossAmount) && ISNULL(CaseReserveAmount)) 
              ?NULL(DT_CY) 
              : (ISNULL(PaidLossAmount) 
                            ? 0 
                            : PaidLossAmount) 
                 + (ISNULL(CaseReserveAmount) 
                            ? 0 
                            : CaseReserveAmount) 
     : PaidLossAmount

Here's a decision tree:

enter image description here

Upvotes: 2

Related Questions