OpenBI Docs Buy

IF.EAGER

As IF, with the same result: Power BI's hint to evaluate both branches first, which OpenBI evaluates as IF.

Group: Logical. Compatible with DAX.

Syntax

IF.EAGER ( <logical_test>, <value_if_true> [, <value_if_false>] )
ParameterTypeDescription
logical_testBooleanThe condition.
value_if_trueValueThe result when the condition is TRUE.
value_if_falseValue
optional
The result when it is not; BLANK when left out.

Returns

Same type as its values. One of the two results, as IF gives it.

Remarks

  • The answer is always the one IF gives with the same arguments.
  • The name is a hint about how to compute, not about what: it is there so that measures written for Power BI with IF.EAGER run unchanged. In a new measure, write IF.
  • A common shape is a condition and two results that share one costly part, often put in a variable first: VAR v = [Revenue] RETURN IF.EAGER ( v > 1000000, v * 0.95, v ).

Compared with DAX

In Power BI, IF.EAGER tells the engine to compute both results before it looks at the condition, which can save work when the two share their expensive parts. OpenBI evaluates IF.EAGER as it evaluates IF, the chosen result only; the answer is the same.

Examples

The same as IF

EVALUATE
VAR Lines = DATATABLE ( "Liters", INTEGER, { { 40 }, { 250 }, { 1200 }, { 0 } } )
RETURN
    ADDCOLUMNS (
        Lines,
        "IF", IF ( [Liters] >= 100, "Big", "Small" ),
        "IF.EAGER", IF.EAGER ( [Liters] >= 100, "Big", "Small" )
    )
LitersIFIF.EAGER
40SmallSmall
250BigBig
1200BigBig
0SmallSmall

A discount above a revenue

Revenue of each product, less 5 % where it passes 20 million.

EVALUATE
SUMMARIZECOLUMNS (
    Products[Product],
    "After discount",
        VAR R = [Revenue]
        RETURN IF.EAGER ( R > 20000000, R * 0.95, R )
)
ORDER BY Products[Product]
Products[Product]After discount
Cider15655848
IPA20178547.2
Lettøl5075370
Pils36256168.6

IF, SWITCH, DIVIDE.

Last updated · OpenBI Studio 0.3.74