Help pinpointing proper formula

Is it possible to create a field with a formula that populates based on which of 2 related fields has a value?

I can't seem to get anything to work and need some guidance.

For example:

ifElse(related($opportunities_contacts_1,"name"),related($accounts_contacts_1,"name"))

Thanks in advance.