Table Calc to sum column except last row

I was able to calculate the sum of a column except the last row with the following table calc:  sum(pivot_row(${TABLE.MEASURE:total})) - max(row())

Is there a way to apply similar logic to sum a column except the last 2 rows, last 3 rows, etc?

thanks in advance!

Solved Solved
1 2 1,107
1 ACCEPTED SOLUTION

Ok figured it out.

Solution:

  1. Getting sum of a column except the last row:  max(running_total(offset(${total_cohort_size}, -1)))
  2. Getting sum of a column except the last 2 rows:  max(running_total(offset(${total_cohort_size}, -2)))
  3. etc, etc. 

View solution in original post

2 REPLIES 2

EDIT:

This logic is wrong:  sum(pivot_row(${TABLE.MEASURE:total})) - max(row())

This resulted in subtracting the total row count and not the value in the last row.

Ok figured it out.

Solution:

  1. Getting sum of a column except the last row:  max(running_total(offset(${total_cohort_size}, -1)))
  2. Getting sum of a column except the last 2 rows:  max(running_total(offset(${total_cohort_size}, -2)))
  3. etc, etc. 
Top Labels in this Space