what a potentially messy / hard to maintain report....
with that said, I would try something like:
in group header
shared stringvar array meds;
shared numbervar medIndex := 1;
redim meds[100];
in details
shared stringvar array meds;
shared numbervar medIndex;
meds[medIndex] := {table.med};
medIndex := medIndex + 1;
in the footer:
there would be lots of loops and ifs but a start would be:
shared stringvar array meds;
shared numbervar medIndex;
if medIndex = 1 then (
if med[1] = "Plavix" then 1
if med[1] = "xxx" then x
)
if medIndex = 2 then (
if (medIndex[1] = "Aspirin" or medIndex[2] = "Aspirin") and (medIndex[1] = "Plavix" or medIndex[2] = "Plavix") then 2
etc.
you might need to formulate some loops if your combinations become too numerous.
HTH