Use a new occurrence of lines, Lines|Sorted, and set up the same relationship, but specify a sort order in the that sorts them by the price field.
Then a calculation field, cIDListAvg, with this calculation:
Let ( IDList = List ( Lines|Sorted::__pkLinesID ) ;
MiddleValues ( IDList ; 3 ; ValueCount ( IDList ) - 4 ) )
Will return the list of IDs for the lines records, but with the smallest two and largest two values omitted.
Now you can add yet another occurrences of Lines:
Invoices::cIDListAvg = Lines|Avg::__pkLinesID
and Average ( Lines|Avg::price )
will return the average price of all but the smallest and largest two prices.