Thursday, March 28, 2024

FCC - Using Entities that are Shared in Insertion Rules

When working with insertion rules, sometimes there is a need to calculate something only for specific entities. But, if that entity is shared - in other words, exists in multiple hierarchies or has multiple owners - there can be problems. Here's how to deal with this common problem.

The need most arises with IF statements. The code usually looks something like this:

IF(@ISMBR("331"))

   do some calcs

ENDIF;


This code will pass validation and deploy successfully, but when trying to consolidate, an error is generated.


Clicking the link and drilling into the error message will show this:

Unable to resolve duplicate member name ["331"] on line ____


The problem is the rule doesn't know whether to run for [ParentA].[331], [ParentB].[331], etc. One workaround would be to write the IF statement like this:

IF(@ISMBR("[ParentA].[331]"))

But if the entity gets moved, then that creates another problem.

The solution is to use the @EQUAL function. @EQUAL searches the outline for the specified string within a specified dimension. The result looks like this:

IF(@ISMBR(@EQUAL("331","Entity")))

If an additional entity existed like 331abc that should not be included, then add an additional condition to the IF statement to exclude that entity.