Forum Discussion
DAX interpreter BUG!!!
Hi, Element115
Although variables can be used anywhere, however, their result might not be always the same. Because they are evaluated in the context in which they are written.
Please refer to this thread for more details.
Caution When Using Variables in DAX and Power BI
Best Regards,
Community Support Team _ Eason
One more thing... I read RADACAD's explanation, however it does not apply here. Look again carefully at the code I posted:
"DownTime", IF ( [ErrorCategory] == "Unreachable",
VAR __unreachable_dt = DATEVALUE([UnreachableSince]) + TIMEVALUE([UnreachableSince])
VAR __unreachable_dt_in_secs = DATEDIFF(__start_date, __unreachable_dt, SECOND)
RETURN
IF( __unreachable_dt_in_secs >= 0,
DATEDIFF(DATEVALUE([UnreachableSince]) + TIMEVALUE([UnreachableSince]), [ClosedDT], SECOND),
BLANK() //DATEDIFF([CreationDT], [ClosedDT], SECOND)
),
__unreachable_dt is declared right before the RETURN statement and when referenced in the RETURN block inside de DATEDIFF() inside the IF() as the 2nd parameter, the result is not that the computation is wrong.
In other words, the block of code is
IF( condition,
VAR __declaration0 = ...
VAR __declaration1 = ...
RETURN
IF( __declaration1 >= 0, // no issues here referencing the second variable
DATEDIFF( __declaration0, ... ) // issue here CAN'T FIND THE VARIABLE!!!
...
Is this really as it should be???
The result is that the interpreter complains the variable does not exist or is not defined! Two very different things, yes?