I think both formulas are doing exactly what I would expect.
The related( function finds the related record, then evaluates the formula with that record as the context for any field values. But datavalue( has it’s own logic for determining what the current context is, so it ignores the context supplied by the related( function.
What are you really trying to do? Do you want the field name to be the result of a calculation? Then you could do something like this.
let targetField = "FieldA"
targetField = "FieldWierd"
let data = related(targetField,"RelatedDatabase")
The documentation says that the first parameter of the related( function must be quoted, but that is really a simplification. The actual rule is that this parameter must itself evaluate to be the formula you actually want to use. Usually, you just put quotes around the formula you want, but you can actually assemble the formula “on-the-fly” if needed.
fileglobal fgVar // it can be "Mail", "Bill", or "Ship"
I have 3 different addresses stored in the related database (Mail to, Ship to and Bill to), and the variable determines which one to get back.