IF.EAGER DAX Function (Logical)

Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE. Uses eager execution plan.

Syntax

IF.EAGER ( <LogicalTest>, <ResultIfTrue> [, <ResultIfFalse>] )
Parameter Attributes Description
LogicalTest

Any value or expression that can be evaluated to TRUE or FALSE.

ResultIfTrue

The value that is returned if the logical test is TRUE.

ResultIfFalse Optional

The value that is returned if the logical test is FALSE; if omitted, BLANK is returned.

Return values

Scalar A single value of any type.

Either ResultIfTrue or ResultIfFalse expression result, depending on LogicalTest.
The result data type can be variant if ResultIfTrue and ResultIfFalse are of different data types. The function attempts to return a single data type if both ResultIfTrue and ResultIfFalse are of numeric data types. In the latter case, the IF.EAGER function will implicitly convert data types to accommodate both values.

Remarks

IF.EAGER has the same functional behavior as the IF function, but performance may differ due to differences in execution plans. IF.EAGER has the same execution plan as the following DAX expression:

VAR _value_if_true = <ResultIfTrue>
VAR _value_if_false = <ResultIfFalse>
RETURN
    IF ( <LogicalTest>, _value_if_true, _value_if_false )

Note: The two branch expressions are evaluated regardless of the condition expression.

Calling IF.EAGER enforce eager evaluation of the conditional expression, instead of relying on choice between strict and eager evaluation made by the DAX engine.

This function should be used only in very particular case of DAX optimization, after verifying that it produces a clear performance advantage compared to the regular IF function.

» 1 related article
» 3 related functions

Examples

--  The engine can use either STRICT or EAGER evaluation. 
--  The choice is up to the optimizer.
--  Using IF.EAGER you can force eager evaluation of IF statements.
--  Useful in some optimization scenarios.
DEFINE
    MEASURE Sales[GrossAmount] = SUMX ( Sales, Sales[Quantity] * Sales[Unit Price] )
    MEASURE Sales[NetAmount]   = SUMX ( Sales, Sales[Quantity] * Sales[Net Price] )
EVALUATE
ADDCOLUMNS (
    VALUES ( 'Product'[Brand] ),
    "Sales",
        IF ( 'Product'[Brand] = "Contoso", [GrossAmount], [NetAmount] * 1.5 )
)
ORDER BY 'Product'[Brand]
Brand Sales
A. Datum 3,144,276.96
Adventure Works 6,016,668.41
Contoso 8,098,022.18
Fabrikam 8,331,023.59
Litware 4,883,556.04
Northwind Traders 1,560,828.19
Proseware 3,819,216.24
Southridge Video 2,076,620.77
Tailspin Toys 487,563.63
The Phone Company 1,685,728.60
Wide World Importers 2,852,934.98

Related articles

Learn more about IF.EAGER in the following articles:

Related functions

Other related functions are:

Last update: Nov 14, 2024   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

Microsoft documentation: https://docs.microsoft.com/en-us/dax/if-eager-function-dax

2018-2024 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Volatile

A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of IF.EAGER? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.