I have a calculated field which is an ifelse statement which checks 2 requirements (both are aggregated fields). When these requirements are met, i want to return report_date (date the data is from). However since this date is not aggregated, i get the error mismatched aggregation. Here are my fields:
report_date - date the data was captured
applicantid - the case reference (this visual is filtered to one)
case_arrears - how much arrears the case is in
PreviousDayArrears - whether yesterday was in arrears or not (returns the amount)
lag(
{case_arrears},
[{report_date} ASC],
1,
[applicantid]
)
EnteredArrearsFlag - flagged when entered arrears for a new period (based on yesterday not being in arrears):
ifelse(
{case_arrears_aggre} > 0 AND PreviousDayArrears <= 0,
1,
0
)
case_arrears_aggre is an aggregated version of case_arrears so it can be used in this calculated field:
sum({case_arrears})
What i want to do is replicate the EnteredArrearsFlag, but instead return the report_date. So then i have a date for each time the case enters arrears. Since this field is not aggregated, it doesn’t work.
Basically, while IsArrears = 1, i want to return the max(EnteredArrearsDate). So it should return what i’ve mocked up quickly. Using this, i will be able to workout days in arrears on a daily basis, however how can i return the EnteredArrearsDate (Aug 4 2024) while IsArrears = 1?