1 Reply Latest reply: Nov 13, 2011 5:37 PM by Stefan Wühl RSS

    Weighted average in a straight table


        I want to create a weighted average in the totals row on a straight table. Basically we want to create a sum product of two columns and divide by sum of one column. Is it possible in qlikview?Thanks

        • Weighted average in a straight table
          Stefan Wühl

          Try something like


          =if(dimensionality()=0,sum(aggr(FIELD1*FIELD2,DIMENSION))/sum(FIELD1), YOURROWEXPRESSION))


          where sum(aggr(FIELD1*FIELD2,DIMENSION))/sum(FIELD1) is calculating the weighted average of FIELD2 weighted by FIELD1, and DIMENSION is your chart dimension (if you have more than one,
          you need to specify all comma separated).


          YOURROWEXPRESSION is the expression you want to show for the table rows.

          If you don't want it different, you just can state

          =sum(aggr(FIELD1*FIELD2,DIMENSION)) / sum(FIELD1)


          Hope this helps,