Set table summary row with calculated fields

I'm currently working on a table component where I need to set up summary rows with calculated fields such as ROAS (Revenue/Spend) and CPC (Clicks/Spend). Could someone please guide me on how to achieve this?

Additionally, I'm facing an issue with text wrapping in both summary rows and heading rows. I need the text to wrap to a second line if it exceeds the width of the cell. Could someone advise on how to implement text wrapping in these scenarios?