Forum Discussion
Help with evaluating some DAX code
- 3 years ago
IF statements work from the top in so it check 1, the 2 etc:
It startts with 1 and IF 'Cases[ERT Start Flag Date] is not blank it goes to section A which starts the 2 check, if it is blank it gos to B and returns a BLANK().
- 3 years ago
Hi ArchStanton
The explanation from jdbuchanan71 is perfect. Regarding your second question, you can use variables in this way:
Days ERT to Outcome = var _startFlag= ISBLANK ( 'Cases'[ERT Start FlagDate] ) var _endFlag= ISBLANK ( 'Cases'[ERT End FlagDate] ) IF ( NOT ( _startFlag), IF ( ISBLANK ( 'Cases'[formofauthorityreceiveddate] ), DATEDIFF ( IF ( 'Cases'[Created Date] > 'Cases'[ERT Start FlagDate], 'Cases'[Created on], 'Cases'[ERT Start FlagDate] ), IF ( _endFlag , NOW (), 'Cases'[ERT End FlagDate] ), DAY ), DATEDIFF ( 'Cases'[ERT Start FlagDate], 'Cases'[ERT End FlagDate], DAY ) ), BLANK () )However, as you can see, it doesn't make much sense. Variables avoid repetitive calculus, but in this case, you don't have repetitive pieces
Hi ArchStanton
The explanation from jdbuchanan71 is perfect. Regarding your second question, you can use variables in this way:
Days ERT to Outcome =
var _startFlag= ISBLANK ( 'Cases'[ERT Start FlagDate] )
var _endFlag= ISBLANK ( 'Cases'[ERT End FlagDate] )
IF (
NOT ( _startFlag),
IF (
ISBLANK ( 'Cases'[formofauthorityreceiveddate] ),
DATEDIFF (
IF (
'Cases'[Created Date] > 'Cases'[ERT Start FlagDate],
'Cases'[Created on],
'Cases'[ERT Start FlagDate]
),
IF ( _endFlag , NOW (), 'Cases'[ERT End FlagDate] ),
DAY
),
DATEDIFF ( 'Cases'[ERT Start FlagDate], 'Cases'[ERT End FlagDate], DAY )
),
BLANK ()
)
However, as you can see, it doesn't make much sense. Variables avoid repetitive calculus, but in this case, you don't have repetitive pieces
Really grateful for your reply as well, many thanks