Forum Discussion
Help need with long DAX code
- 1 year ago
Hi ArchStanton - Absolutely! inline comments you can reuse it eg: // . This measure calculates the number of days a case spent
Days in Adj =
IF (
// Check if any of the adjudication-related date fields are not blank
NOT ( ISBLANK ( 'Cases'[datepassedtoadjudication] ) )
|| NOT ( ISBLANK ( 'Cases'[dateassignedforadjudication] ) )
|| NOT ( ISBLANK ( 'Cases'[dateacceptedforinvestigation] ) ),// If the case has not been resolved yet (no resolution date), calculate days until today
IF (
ISBLANK ( 'Cases'[Resolution Date] ),
DATEDIFF (
// Determine the earliest adjudication date to start counting from
IF (
ISBLANK ( 'Cases'[datepassedtoadjudication] ),
IF (
ISBLANK ( 'Cases'[dateassignedforadjudication] ),
// Fallback if both other dates are blank
'Cases'[dateacceptedforinvestigation],
// Use dateassignedforadjudication if available
'Cases'[dateassignedforadjudication]
),
// Prefer datepassedtoadjudication if available
'Cases'[datepassedtoadjudication]
),
NOW (), // Use current date if no resolution
DAY
),// If the case has been resolved, calculate days until resolution date
DATEDIFF (
IF (
ISBLANK ( 'Cases'[datepassedtoadjudication] ),
IF (
ISBLANK ( 'Cases'[dateassignedforadjudication] ),
'Cases'[dateacceptedforinvestigation],
'Cases'[dateassignedforadjudication]
),
'Cases'[datepassedtoadjudication]
),
'Cases'[Resolution Date],
DAY
)
),// If no relevant adjudication dates exist, return blank
BLANK ()
)HOpe this helps.
Hi ArchStanton - Absolutely! inline comments you can reuse it eg: // . This measure calculates the number of days a case spent
Days in Adj =
IF (
// Check if any of the adjudication-related date fields are not blank
NOT ( ISBLANK ( 'Cases'[datepassedtoadjudication] ) )
|| NOT ( ISBLANK ( 'Cases'[dateassignedforadjudication] ) )
|| NOT ( ISBLANK ( 'Cases'[dateacceptedforinvestigation] ) ),
// If the case has not been resolved yet (no resolution date), calculate days until today
IF (
ISBLANK ( 'Cases'[Resolution Date] ),
DATEDIFF (
// Determine the earliest adjudication date to start counting from
IF (
ISBLANK ( 'Cases'[datepassedtoadjudication] ),
IF (
ISBLANK ( 'Cases'[dateassignedforadjudication] ),
// Fallback if both other dates are blank
'Cases'[dateacceptedforinvestigation],
// Use dateassignedforadjudication if available
'Cases'[dateassignedforadjudication]
),
// Prefer datepassedtoadjudication if available
'Cases'[datepassedtoadjudication]
),
NOW (), // Use current date if no resolution
DAY
),
// If the case has been resolved, calculate days until resolution date
DATEDIFF (
IF (
ISBLANK ( 'Cases'[datepassedtoadjudication] ),
IF (
ISBLANK ( 'Cases'[dateassignedforadjudication] ),
'Cases'[dateacceptedforinvestigation],
'Cases'[dateassignedforadjudication]
),
'Cases'[datepassedtoadjudication]
),
'Cases'[Resolution Date],
DAY
)
),
// If no relevant adjudication dates exist, return blank
BLANK ()
)
HOpe this helps.
- ArchStanton1 year agoPower Participant
This is great thanks!!