I am struggling with the below array formula as it returns a "too few arguments" error.

Excel Formula:

`=SUM(IF(FREQUENCY(IF('Medication log'!$E$13:$E$50000=C2,IF('Medication log'!$H$13:$H$50000,"Yes",IFERROR('Medication log'!$F$13:$F$50000+0, "")))),ROW(INDIRECT("44044:45100")))+FREQUENCY(IF('Reminder diary'!$E$13:$E$50000=C2,IF(‘Reminder diary’!$S$13:$S$50000,”Yes”,IFERROR('Reminder diary'!$F$13:$F$50000+0,""))),ROW(INDIRECT("44044:45100"))),1))`

- analyzing data on

**Medication log**- and on

**Reminder diary**tabs, for cases when entries in column E matches entry in cell C2 on "main" tab

- the goal is to have total number of unique dates across both tabs (there may be partial overlap) for the condition in previous bullet; dates are listed in column F on both tabs

- at the same time, these unique dates must only be counted when there's also a "Yes" in column H in

**Medication log**tab, or "Yes" in column S in

**Reminder diary**tab. Otherwise these dates should be ignored in overall calc.

What am I doing wrong please?