Forum Discussion

Matt_Vaughn's avatar
Matt_Vaughn
Copper Contributor
Jan 13, 2020

How to weight counts in pivot tables

Hi all!

 

I'm so excited to join this community. I was hoping to find some help about an issue I haven't been able to figure out on my own. I have attached a screenshot of a simplified version of the issue for reference. 

I need the weighted counts of each category (the Count*AVERAGE(WEIGHT) Column) to appear in the pivot table by themselves. So in this case, 7.45 for Apple and 2.6 for Banana. I need to be able to do this for as many variables as possible, and I need it to work with filters. For instance, if I chose to filter to show only people who selected Blue, it would show .85 Banana and (1.15+1.25+0.9+1.05) Apple. This calculation can be done by multiplying the count by the average of the weights, I hope that the filtering function behind pivot tables can also keep the weights assigned to each column to average them out.

 

I know that I will need to do a calculated field multiplying the pivot table count column by the average of the weight column. I would like to be able to do this automatically for all columns, so any new column I add (say "favorite animal") would show up as weighted if I moved its data into the pivot table.

 

Thank you so much!

7 Replies

  • Toni_Roschtscha's avatar
    Toni_Roschtscha
    Copper Contributor

    Matt_Vaughn 

     

    Hi Matt 

    I am trying to do the same thing you are, did you ever find a way of accomplishing using a weighted average with a count function? 

     

    Thanks!

    Toni

  • Riny_van_Eekelen's avatar
    Riny_van_Eekelen
    Platinum Contributor

    Matt_Vaughn 

    Since you managed to count the number of Fruit, I'm confident that you can also drag the Weight field into the value area of the pivot table and change its attribute to "Average" rather than "Sum".

    • Matt_Vaughn's avatar
      Matt_Vaughn
      Copper Contributor

      Yes, but how do I multiply the average by the count within the pivot table and only show the end value?

      • Riny_van_Eekelen's avatar
        Riny_van_Eekelen
        Platinum Contributor

        Matt_Vaughn 

        I don't follow. Count X Average Weight would be the same as SUM of Weight. You can test it by adding another value field, like:

        By the way, I deleted my example that I used in my first response. Therefore you see Name and Value in stead of Fruit and Weight.

         

Resources