Set field value automatically using data from connected record

I'd love to be able to set a field value based on information from the connected record using some logical / sql type lookups. For instance, I have a customer object with connected invoices. I'd like to be able to have a field in the customer table for 'most recent invoice' and 'most recent invoice line item count', where these look at the actual connected records at run time to populate the correct values.

Right now, I can set these based via form rules at submission through the interface builder, but it's not elegant, and frequently doesn't hit every use case. For instance, when I create an invoice, I change the 'most recent invoice' field in the connected customer account to the date of the invoice, but if I go back later and delete that invoice, there is no easy way to set the 'most recent invoice' field to the invoice immediately prior.

*Of note*, when displaying the table of customer accounts, where I'm hoping to show these two fields, I can show fields from connected invoices, but because there the customer - invoice connection is a one-to-many, it will show all of the invoice dates, with an option to separate them by a comma or a newline. If I could use a filter at that point to only show the one most recent, etc, it would also solve the problem.


UPDATE: 

*Of note*, when displaying the table of customer accounts, where I'm hoping to show these two fields, I can show fields from connected invoices, but because there the customer - invoice connection is a one-to-many, it will show all of the invoice dates, with an option to separate them by a comma or a newline. If I could use a filter at that point to only show the one most recent, etc, it would also solve the problem. <-- use CSS to hide overflow after newline?

Haven't played with this, but I bet it would work...

I had a similar situation, except in my case all the fields were numbers - which made it fairly straight forward.

So this may or may not help you :)
If your Invoice number is incremental and is a 'number' formatted field. You can create a new field in your Customer object using the field type Formulas > Maximum and set it to the invoice number of your connected child object.

This should then only show you the highest invoice number connected to that customer. Assuming the invoice number is incremental (higher the number the more recent) and it's a number only field. If it contains letters, or is not incremental, this obviously wouldn't work.