Saturday, December 19, 2015

OBIEE - Using condition ? value-if-true : value-if-false format with Variables

When Evaluating variables in OBIEE formula we usually use the case statement. 
Something like case when '@{PV}'='Yes' then 'YES' else 'NO' end 
 Or case when @{PV}=1 then 'YES' else 'NO' end

Sometimes for clarity we would rather have the entire if-then-else embedded in the Variable curly brackets . In that case we can use the javascript / C ... syntax of
 condition ? value-if-true : value-if-false 

To repeat the previous examples:
'@{(PV=='Yes')? 'YES':'NO'}'

'@{(PV==1)? 'YES':'NO'}'

In both cases NO is the default.

Of course we are not limited to equal condition. All the options (!=, >, <, <=... ) are valid.

If you remember my Selecting columns dynamically saga, the following would work as well:

@{(PV=='Year')? '"Time"."Per Name Year"':'"Time"."Per Name Qtr"'}

By the way, this is one of many interesting things I found in the great OBIEE knowledge source of OBIEE Samples VM.

No comments:

Post a Comment