when you select flat rate, there is a text box to enter the flat rate:
Create a Flt rate Shipping of $[text box]
enter that code in the text box
Create a Flt rate Shipping of $[(($this->TotalColumn('TotalPrice') * 0.1) > 4)?$this->TotalColumn('TotalPrice') * 0.1:4]
(Without the square brackets, I am using them to illustrate the text box)