Code action DR011
(Readability) Rewrite using ISBLANK
Description
Instead of comparing an expression with the value returned by BLANK()
, use the ISBLANK
function.
Example
Change:
IF(
Document[Type] == BLANK(),
[Sales Amount],
[Sales Amount] * 1.25
)
To:
IF(
ISBLANK(Document[Type]),
[Sales Amount],
[Sales Amount] * 1.25
)
Why is Tabular Editor suggesting this?
The ISBLANK
function is a more concise and easier to read way of checking if an expression returns a blank value. By using ISBLANK
, the code becomes more readable and the intent of the expression is clearer.
Remarks
This code action only applies to strict equality comparison (==) with BLANK()
. The regular equality comparison Document[Type] = BLANK()
does not produce the same result as ISBLANK(Document[Type])
if [Type]
is an empty string, or zero (in which case ISBLANK(Document[Type])
would return FALSE
while Document[Type] = BLANK()
would return TRUE
).