I am straining to make sense of all these entities you are mentioning: "levels", "pieces", "items", "base cases", "product".
My best guess as to what you are describing is that you have a parent table and a child table and the price or cost associated with each child item needs to be marked up in a special way.
I think what you are saying is that the cost or price of each child record has to summed up and that sum has to be put through some type of graduated function that has 40 breakpoints - like calculating a tax using 40 different income levels. In other words the markup depends on the total cost or price of the children. The output of this 40 level calculation yields a percentage or markup which has to be allocated to each of the items in the child table. Is that what you are trying to describe?
If this is so you need a summary field in the parent that give you a [total] and then a 40 breakpoint If() formula that yields a markup percentage. The child records lookup to the parent for the markup and multiply it by the child's price or cost.