As in the example given, not just the final result.

TMR's formula does what I wanted.