I still think you are complcating it.
you can have one characterstic "row" formate numeric
second "column" formate numeric
Then as row and colument decides the total cavatiy, you have characterstic cavity, format numeric and assign a procedure which will calculate quantity for this filed as
$SELF.CAVITY = $SELF.ROW*$SELF.COLIMN
Now based upon value calcuated you have multiple value characterstic chemicals which will have list of chemicals selected by users.
If this quantity should match with quantity of cavity then you may need to write up anothe rdependency to restrict it.
Check and reply.
Hope it will help you.
Thanks
Ritesh