This content has been marked as final. Show 8 replies
If you're sure you've set up the relationship correctly using relationship text 'the children', the only other thing it is likely to be is that you haven't declared 'the number of children for the citizen' and 'the number of included children for the citizen' as number variables. The text equivalent of InstanceCount(<relationship>) is the number of (<relationship>), so if you haven't declared your variables first then this is how OPM will try and interpret your rule (as the wording matches).
I haven't confirmed that this suggestion resolves your specific issue but in terms of best practice ...1 person found this helpful
The relationship from citizen to children should be "the citizen's children". Substitution, parsing and clarity of rules are all improved with this approach. For example, "Joe Citizen's children", no ambiguity on whose children you are counting in the InstanceCount rule etc.. For example, your current rule appears as if you are counting all children to compute the number of children of each specific citizen (at least when reading the rule literally without knowledge of the model).
Changed the relationship text to 'the citizen's children' and the rule to read :
the number of included children for the citizen = InstanceCountIf (the citizen's children, the child is included in plan)
Still getting the same compile error :
Error after 'the number of '. Found: 'included children for the citizen = InstanceCountIf (the citizen's children, the child is included in plan)'.
Expected :Unable to find a relationship belonging to the entity 'the citizen'.
Tried by declaring 'the number of included children for the citizen' as a number variable and then recompiling the rule.
Getting a new error :
Error after 'the number of included children for the citizen = '. Found: 'InstanceCountIf (the citizen's children, the child is included in plan)'.
Expected: expression, variable, constant
Try removing the space between InstanceCountIf and the parenthesis.1 person found this helpful
My issue was solved by removing the space and declaring the result 'the number of included children for the citizen' as a variable/ attribute beforehand.
the number of included children for the citizen = InstanceCountIf(the citizen's children, the child is included in plan)
I have a similar problem and would be very glad if anyone could help me.
My design is as follows, using OPM 10.3.1:
global (level 1)
has 0...many Households (level 2)
have 0...many Residents (level 3)
What I would like to do is to get the sum of all Salaries of female residents.
If I try to use all_male_salary = InstanceSumIf(Household's Residents, resident_salary, resident_gender="Female") the following error occurs while compiling: "unable to find a relationship belonging to the entity 'global'".
The same applies to InstanceCountIf.
How would it be possible to get level 3 data on level 1 and store the sum/count in a lvl 1 attribute? (with lvl 2 all works fine).
Not sure how you have named the entities, but assuming you have:
Global -> the household -> the household's resident
You should do this in two separate calcs, the first to work out the combined female salary of the household (at the household entity level), and the second to sum the figures from each household (global). E.g:
the household's total female salaries = InstanceSumIf(the household's residents, the household's resident's salary, the household's resident's gender = "female")
the combined salary of all females = InstanceSum(the households, the household's total female salaries)