Cannot Reference Self - Dynamic Attribute Calculated Expression

This seems pretty standard SQL. We have other expression that are way more complex.

Cannot figure out what this error means. Any ideas?


What is “HEAD”? I think you need to define that better. Normally I use Case When. Im not sure what the syntax you pasted is supposed to do.

3 Likes

I’ve always seen it where Case When is together, more like the below:

(CASE
WHEN HEAD - Other.MinThkOvrride = 0 THEN HEAD - OTHER.MinThkCalc
ELSE HEAD - Other.MinThkOvrride
End)
2 Likes

yeah that my norm too but both are valid - this is how the functions template does it so it tried it their way. :man_shrugging:

It’s just an alternate way to write it. It can reduce repetition and keep it “simpler”, but for anything more convoluted than a single check you’ll end up reverting to Case When.

Example:

CASE PartPlant.Plant
WHEN 'Plant1' THEN '1'
WHEN 'Plant2' THEN '2'
WHEN 'Plant3' THEN '3'
--etc
ELSE ''
END

instead of

CASE
WHEN PartPlant.Plant = 'Plant1' THEN '1'
WHEN PartPlant.Plant = 'Plant2' THEN '2'
WHEN PartPlant.Plant = 'Plant3' THEN '3'
ELSE ''
END
2 Likes

the Dyn Class is called ‘HEAD - OTHER’ so real SQL would be like
[HEAD - OTHER].[MinThkOverride]
but how it’s shown is how they want it - works on other calcs, doesn’t work with brackets. :man_shrugging:

Way over my head! Let us know what you figure out!

1 Like

Meanwhile this one works great. :rofl:

Thought it may be because I’ve referenced and calculated attribute in another calc but that doesn’t appear to be the problem and I’m pretty sure I’ve done so before. :man_shrugging:

FYI - This is a calculated attribute of a Dynamic Attribute Class. It calulates the Minimum Thickness of a dished vessel head (round end of a tank) using a matrix of thinning factors by diameter/thickness.

Much like any BAQ calculated field except the Dynamic Attribute Class name is used in expressions as if a table name.

1 Like

Turns out their self-reference checker is poorly done.

For setting attribute named HEAD - OTHER.MinThk
this works fine:

CASE HEAD - OTHER.OverrideMinThk
    WHEN 0 THEN HEAD - OTHER.CalcMinThk
    ELSE HEAD - OTHER.OverrideMinThk
END

while this doesn’t (notice HEAD - OTHER.MinThk exists in HEAD - OTHER.MinThkCalc)

CASE HEAD - OTHER.MinThkOverride
    WHEN 0 THEN HEAD - OTHER.MinThkCalc
    ELSE HEAD - OTHER.MinThkOverride
END

presumably because they do a simple check to see if the string HEAD - OTHER.MinThk exists in the expression. Rather than also ensure it’s followed by a space or another character to avoid false positive matches.

Pretty sure BAQ calculated expressions don’t do this poorly. or if they do I suppose the forced ‘Calculated_’ prefix avoids false positives in BAQs.

I have to ask why you decided to go with multiple whens instead of using IN. Personal preference or is there a functional gain? Something like this.

CASE 
  WHEN HEAD - OTHER.NomThk IN (0.1050, 0.1200, 0.1350, 0.1870, 0.1875, 0.2500, 0.3125) 
  THEN 0.0625 
  ELSE 0 
END
1 Like

Good question, maintainabilty is all. The matrix is used across several classes and can differ across Suppliers. Decision makers were undecided, so I made the expression atomic for those reasons. They can easily change a thinning factor without considering SQL logic.

Plus, some are not as straight-forward as others.


1 Like