2 Replies Latest reply on Aug 22, 2018 8:58 AM by Ankit Bansal

    Average if

    Ewa McKillop

      Hello

       

      I am quite new to Tableau and I am stuck at one calculation.

       

      I have weekly data with different products, different customers and their unit sales.

       

      I'd like to calculate: IF the average unit price each week is higher than in the parameter,  then I'd like to calculate the average of weekly base sales  for these weeks.

       

      Calculation:

      AVG(if [AUP weekly]>[Promo Price] then [Unit Sales] else Null

      END)

       

      Calculated field [AUP weekly] = {FIXED[Date], [Manufacturer]:[AUP]

       

      Promo Price is a parameter.

       

       

      ***I've used a similar calculation to calculate how many weeks on promotion a product is each year and the calculation is working, so I tried to follow the same logic, but I think I am missing something:

      COUNTD(if [AUP weekly]<[Promo Price] then [Date] else Null

      END) ***

       

      Thanks

       

      Ewa