Hi @Whitewater100
Update Next Assessment Due Date and Next Assessment Calculated Columns with this
Next Assessment Due Date =
VAR _FirstDate = [Baseline Assessment Date]
VAR _Today = TODAY()
VAR _Days = DATEDIFF(_FirstDate,_Today,DAY)
VAR _BaseAssessment = LOOKUPVALUE('Assessment Code'[Assessment Code Detail],'Assessment Code'[Assessment Code], 600)
VAR _Assessment_1 =
CALCULATE(
SELECTEDVALUE('Assessment Code'[Assessment Code Detail]),
FILTER('Assessment Code',
_Days >= 'Assessment Code'[Open Window] &&
_Days <= 'Assessment Code'[Close Window])
)
VAR _Assessment = IF(_Assessment_1 = BLANK(), _BaseAssessment,_Assessment_1)
VAR _CheckLastAssessment = IF([Last Assessment] = _Assessment,TRUE(),FALSE())
VAR _Months = LOOKUPVALUE('Assessment Code'[Months],'Assessment Code'[Assessment Code Detail],_Assessment)
VAR _NextAssessmentMonth =
IF(_CheckLastAssessment,
CALCULATE(MIN('Assessment Code'[Months]),
FILTER('Assessment Code', 'Assessment Code'[Months] > _Months)),
_Months)
VAR _DueDateCurrentAssessment = _FirstDate + (_Months * 30)
VAR _DueDateNextAssessment = _FirstDate + (_NextAssessmentMonth * 30)
VAR _CurrentAssessment = IF(_CheckLastAssessment,_DueDateNextAssessment,_DueDateCurrentAssessment)
Return IF(Pateints[Patient Discharge],BLANK(),_CurrentAssessment)
and
Next Assessment =
VAR _FirstDate = [Baseline Assessment Date]
VAR _Today = TODAY()
VAR _Days = DATEDIFF(_FirstDate,_Today,DAY)
VAR _BaseAssessment = LOOKUPVALUE('Assessment Code'[Assessment Code Detail],'Assessment Code'[Assessment Code], 600)
VAR _Assessment_1 =
CALCULATE(
SELECTEDVALUE('Assessment Code'[Assessment Code Detail]),
FILTER('Assessment Code',
_Days >= 'Assessment Code'[Open Window] &&
_Days <= 'Assessment Code'[Close Window])
)
VAR _Assessment = IF(_Assessment_1 = BLANK(), _BaseAssessment,_Assessment_1)
VAR _CheckLastAssessment = IF([Last Assessment] = _Assessment,TRUE(),FALSE())
VAR _Month = LOOKUPVALUE('Assessment Code'[Months],'Assessment Code'[Assessment Code Detail],_Assessment)
VAR _NextAssessmentMonth =
IF(_CheckLastAssessment,
CALCULATE(MIN('Assessment Code'[Months]),
FILTER('Assessment Code', 'Assessment Code'[Months] > _Month)),
999)
VAR _NextAssessment = LOOKUPVALUE('Assessment Code'[Assessment Code Detail],'Assessment Code'[Months],_NextAssessmentMonth)
VAR _CurrentAssessment = IF(_CheckLastAssessment,_NextAssessment,_Assessment)
Return IF([Patient Discharge],BLANK(),_CurrentAssessment)
SPARSR - jbressanV2.pbix (252.4 KB)