Victoria Ubaldo
Victoria Ubaldo

Reputation: 99

Using WINDOW_SUM formula with each row in Tableau

I have a migration from excel to Tableau. In Tableau I want to create some calculate field :

            Cant Calculation
             10  1.982332155
             14  1.939929329
             17  1.885159011
             20  1.819787986
              .
              .
Grand Total  566

Calculation (excel) : =+(SUMA(A2:$A$11)+SUMA(A3:$A$11))/$A$12

The problem is in Tableau, repeat the calculate field in all the column.

            Cant Calculation
             10  1.982332155
             14  1.982332155
             17  1.982332155
             20  1.982332155
              .
              .
Grand Total  566

I've tried with this calculation:

(WINDOW_SUM(SUM([Cant]),FIRST(),LAST())+ WINDOW_SUM(SUM([Cant]),FIRST()+1,LAST()))/TOTAL(sum([Cant]))

Thanks for your help.

Upvotes: 1

Views: 1698

Answers (1)

MonteCarloSims
MonteCarloSims

Reputation: 1771

To complete this with a Table Calculation, you must tell Tableau how to it should aggregate rows. You do this by:

Right click on table calc when on the view (note the little triangle graphic) > 
"Compute using"   - OR -   "Edit Table Calculation..."

I'm guessing in your case you will need to choose Edit Table calculation, and then select "Restarting every" [cant]. However, this element of the task is going to be very customized to your data and what else is on the view. The nice thing, though, is that the view will adjust real-time as you click around in the dialog box to help you discover the correct format.

I might also suggest using an LOD calculation in place of a Table Calculation here. At the very least, LOD calculations are something that you should research for the future. They are similar to Table Calculations in the kinds of answers they can provide, but they are different in that they operate on the data level, as opposed to 'what is seen on the view (table) currently'.

Upvotes: 1

Related Questions