Hi MEDFAR ,
Try CASE statement to check if number of AppointmentId is greater than 1 within multipass aggregation.
The formula would be something like this:
(SUM([PatientId],
case when (COUNT([AppointmentId]), [AppointmentDate]) > 1
then 1
else 0
end)
-Hari