It's not going to work that way.
The rule is executed once and not once per row, so you can't reference a row in it.
The solution is probably to hand code your discount calculation on your cart page. Manually create a loop that loops through the recordset and finds the discount amount, then stores it as a Session variable on the cart page.
Then the rule becomes simplified to just do a flat rate charge of the Session variable value when the Session variable exists and all of the complex rule calculations are handled by the code you write on top of the cart.php page.
This is something we could help with in a premier support ticket.