I have a stored procedure that returns a bunch of rows in one column like the following example:

ID
A
B
C
D
E

Now, in the report, i have the following layout

_A _B _C _D _E

i want to loop thru the stored procedure results and determine if a letter exists in the results. If the letter exists, i would like to mark the correct character. For example, if A and C exists, the report would look like this:

XA _B XC _D _E

I'm using formula fields but its only reading the first row. How do check each row in the results?

Code:
 if  {USP...} = "A" then
"X"