KB 101400
Function replace DISTINCTCOUNT/HASONEVALUE
DISTINCTCOUNT function can be replaced by HASONEVALUE.
Remarks
The code that compares the result of DISTINCTCOUNT with 1 can be replaced with the function HASONEVALUE. This recommendation does not have a relevant impact on performance, but it is a best practice that improves code readability.
Example
Replace DISTINCTCOUNT and the comparison with HASONEVALUE.
Original code
IF (
DISTINCTCOUNT ( Customer[CustomerKey] ) = 1,
"Customer Name : " & Customer[Name],
"Undefined"
)
Possible optimization
IF (
HASONEVALUE ( Customer[CustomerKey] ),
"Customer Name : " & Customer[Name],
"Undefined"
)