Lookup from table via formula in an IF statement

I’ve got 3 tables:

  • Organizations
  • Opportunities (an opportunity always belongs to exactly one organization)
  • Log Entries

A log entry could be about either an organization in general or a specific opportunity.
Currently in Log Entries I have two lookups, to the tables Organizations and Opportunties.

Here is what I want:
When a Log Entry is about an Opportunity, the Organization should automatically be populated.
I achieved this by creating this formula in the Organization column:
If(IsNotBlank(thisRow.Opportunity),thisRow.Opportunity.Organization ,"How to have a lookup to Organizations here?" )

But if the log entry IS NOT specifically for an Opportunity, then I’d like to have the normal lookup to Organizations. How to do that? Thanks for the help!