So the accumulation needs to restart when Filial Commercial changes? You will need to use Aggr() function to get this fixed. Exact expression would be rather difficult to provide because of the complexity, but if you can provide a sample, we might be able to help