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>] )
| Parameter | Type | Description |
|---|---|---|
logical_test | Boolean | The condition. |
value_if_true | Value | The result when the condition is TRUE. |
value_if_false | Value 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
IFgives 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" )
)
| Liters | IF | IF.EAGER |
|---|---|---|
| 40 | Small | Small |
| 250 | Big | Big |
| 1200 | Big | Big |
| 0 | Small | Small |
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 |
|---|---|
| Cider | 15655848 |
| IPA | 20178547.2 |
| Lettøl | 5075370 |
| Pils | 36256168.6 |