8 Replies Latest reply: Apr 17, 2018 2:14 PM by Vishwarath Nagaraju RSS

    How to calculate an average of three cheapest / most expensive products?

    Frank Schuenemann

      Good Morning,

       

      I have a question of how to calculate the average of  the 3 cheapest products in a list / respectively the three most expensive products in a list products with prices at a certain Date.

       

      Example:

       

      DatProductPrice
      1.2.18A10,00
      1.2.18B9,78
      1.2.18C9,90
      1.2.18D7,55
      1.2.18E5,54
      1.2.18F6,70
      1.2.18G3,30
      1.2.18H2,90
      1.2.18I2,90
      1.2.18J9,97
      1.2.18K9,97
      1.2.18L9,97
      1.2.18M2,31
      1.2.18N2,31
      1.2.18O2,31
      1.2.18P0,98
      1.2.18Q

      0,99

       

      As a result for the "average of the 3 most expensive" I would like to see:  Average = 9,98

       

         

      DatProductPrice
      1.2.18A10,00
      1.2.18J9,97
      1.2.18K9,97

       

      (A+J+K )/3= 9,98

       

      Remarks:

      a) Although the Price of product "L" is the same as "J" and "K", it is not taken into account, because I only Need the first three cheapest products.

      c) In case  there are only two products in the list, (e.g. at Date "Dat 1.3.18"  only Product A and B) the calculation should be A+B/2.

       

      I have tried it in many ways, but without acceaptable results.

      Thanks for your help!