2 Replies Latest reply on Oct 17, 2018 12:35 AM by Chadi Atie

    How to calculate the weighted average?

    Chadi Atie

      Hi Guys,

       

       

      I have this workbook in the screenshot above:

       

      I need to add the WEIGHTED AVERAGE instead of the average, is this possible to do it in Tableau?

       

       

      Weighted average would be something like this:

       

      Value of KPI (Price) in Month (Jan) * Value of KPI (Sales) in Month (Jan)

                                                               +

      Value of KPI (Price) in Month (Feb) * Value of KPI (Sales) in Month (Feb)

                                                               +

      Value of KPI (Price) in Month (Mar) * Value of KPI (Sales) in Month (Mar)

                                                               +

      ..... For all the months

                                                               /

      Value of KPI (Sales) in Month (Jan) + Value of KPI (Sales) in Month (Feb) + Value of KPI (Sales) in Month (Mar) + ... For all the months

       

       

       

      Thanks a lot,

      PS: Workbook attached

       

      Chadi

        • 1. Re: How to calculate the weighted average?
          Paul Cawford

          Hi Chadi,

           

          Are you able to re-arrange your data source to read like:

           

          Date | Shipment | Prices | Sales

           

          Where shipment, prices and sales are the values for said date?  If not I have done this within tableau by using some custom join calculations and a data source filter.

           

          I.e.

          The same data source renamed and joined:

           

          Join calculation from Prices to Sales:

           

           

          Join calculation from Prices to Shipment:

           

          And the data source filter applied to the 'Prices' table:

           

           

          Obviously the above join can be avoided if you can set your data source to the suggested format.

           

           

          Once you have carried out this step it's a simple matter of writing the formula which is:

           

           

          This should calculate the weighted average for any time frame that you are interested in.  Please see the attached working example:

           

           

           

          1 of 1 people found this helpful
          • 2. Re: How to calculate the weighted average?
            Chadi Atie

            Great thanks man,

             

            Would you be able to also tell me how you did the join calculation within Tableau to reformat the structure of the Table?

             

            Thanks a lot,

            Chadi