Incorrect result of divide or multiply two CumulativeSum expressions

Hello, I'm trying to divide two columns with CumulativeSum, but it doesn't work, the result is wrong. I give you an example:

The column "Acumulado RN" is a CumulativeSum(RN). The column "Capacidad Acumulada" is a CumulativeSum(CapacidadDia). As it can be seen, the values of those columns are correct, however, when I divide CumulativeSum(RN)/CumulativeSum(CapacidadDia) the result is wrong, you can see it in the column "cumcum".

I've tryed to create a custom column before the aggregation called CapacAcum which have CapacidadDia*Numer of days, which is a way to do a cumulative manually. The result is in the column "CC_CapaAcum" and it's correct. Nevertheless, if I divide CumulativeSum(RN)/Sum(CapacAcum), the result is wrong again, you can see it in the column "%Acumulado Mes". In this case, it seems that always divide AcumuladoRN/CapacidadDia instead of the cumulative :frowning:

Is it impossible to do this? I've seen that cumulatives work with + or -, but it doesn't work if you multiply or divide them.

I wrote in another topic but I was told it wans't the right topic, I'm sorry, so I'm creating a new one. I've seen several discussions about this issue, for example: https://github.com/metabase/metabase/issues/15118 but I'm not sure if there is any solution for this problem. Please, can you help me?

Thanks in advance!

@Adriana1 You would have to do your cumulative calculation in SQL. There's no workaround in the GUI currently.

It seems you're encountering an issue with dividing or multiplying two CumulativeSum expressions. This could be due to several reasons:

  1. Misunderstanding of CumulativeSum: Ensure that you're correctly understanding what the CumulativeSum expression represents in your context. It's essentially the cumulative sum of a sequence of values.

  2. Boundary Conditions: When dealing with cumulative sums, it's important to consider the boundary conditions. Make sure your expressions handle the initial conditions correctly.

  3. Implementation Errors: Check for errors in the implementation of your divide or multiply operations involving CumulativeSum expressions. Ensure that you're performing the operations correctly with respect to the cumulative nature of the data.

  4. Data Consistency: Ensure that the data you're operating on is consistent and properly aligned for the operations you're trying to perform. Mismatched or inconsistent data can lead to incorrect results.

  5. Debugging: Break down your operations into smaller steps and debug each step to identify where the issue might be occurring. Verify intermediate results to pinpoint the source of the problem. go language tutorial

  6. Mathematical Correctness: Double-check the mathematical correctness of your operations. For example, division by zero or multiplication by zero could lead to unexpected results.