Knowledge Base
Open App
KB 101500

Redundant functions HASONEVALUE/SELECTEDVALUE (generic)


The expression involving HASONEVALUE and SELECTEDVALUE functions can be optimized by removing HASONEVALUE.

Remarks

SELECTEDVALUE returns a non-blank value when there is only one value visible in the referenced column. Embedding SELECTEDVALUE in a condition related to HASONEVALUE can be redundant: removing HASONEVALUE can slightly improve the performance. The code must be refactored so that it returns the same value as the original code, which might be not possible in certain scenarios.

Example

Remove the outer IF function and the HASONEVALUE condition.

Original code

IF (
    HASONEVALUE( Customer[Country] ),
    IF (
        SELECTEDVALUE( Customer[Country] ) = "Canada",
        [Sales Amount]
    )
)

Possible optimization

IF (
    SELECTEDVALUE( Customer[Country] ) = "Canada",
    [Sales Amount]
)