Custom function for each row

Custom function for each row

I am still new to deluge and have never made a custom function. I am creating a custom function that totals the price field in subform entries. I have tried using "for each," but I can't grasp what the arguments are supposed to be to make it work correctly. I could configure it to recognize there was more than one line item, but it just multiplied the first line item by the number of rows. Any help would be appreciated.