I can’t explain why your [~] relative reference is breaking.
Ignoring the good advice to translate as much as possible in the UI (even if POU is outside Ignition)…
Side note: I would put the entire path to the enumeration table in the custom property, instead of just a part of the path. I would want the flexibility to look at the enum table wherever it exists in the tag database, be able to utilize relative referencing ([.], [~], etc.), and not be confined to a single folder of a provider. Additionally, I typically prefer an array tag, except for cases where large gaps in the enum table exist (an Engine Annunciator Fault Code table, for example). I would not utilize any script to perform this transform, regardless of UI-based or tag-based solution. I would also use an expression tag, not a derived tag, as I can’t envision a reason to ever write a value back to this (or the source) tag. To each-their-own here.
See below for a good reference to options for building tag paths within expressions:
Near the bottom, you’ll see the syntax to reference a custom property of ‘this tag’ (hereon, ‘this’ will refer to a tag that is intended to contain the resultant string post-lookup):
{this.name}
To retrieve your custom property from ‘this tag’:
{this.myCustomProperty}
To have access to the enum table (assuming its entire path is contained in the value of ‘myCustomProperty’), wrap the value of the prop in a tag() expression:
tag({this.myCustomProperty})
To access a specific row of the array tag:
tag({this.myCustomProperty})[<row_number>]
If using another tag’s value (in this example, the tag’s name is ‘EnumValue’, residing in the same folder)
tag({this.myCustomProperty})[{[.]EnumValue}]
To access a specific row & column of a dataset tag:
tag({this.myCustomProperty})[<Row_Index>, <"Column_Name" -OR- Column_Index>
tag({this.myCustomProperty})[{[.]EnumValue.value}, "Text"]
Or, if there are gaps in your dataset, and you must use lookup:
lookup(tag({this.myCustomProperty}), {[.]EnumValue.value}, “ERROR”, "Value", "Text")
You can also substitute column indexes if desired: “Value” –> 0, and “Text” –> 1.
With the above, a ‘myCustomProperty’ value of either ‘[~]…’ or ‘[]…’ should function as expected.