10 Replies Latest reply on Jul 23, 2018 1:22 PM by Shinichiro Murakami

    Change Measure used in Calculated Field, condition on Date

    Paulina Hlavacek

      Hello Tableau Community,


      I am trying to create a Calculated field that uses different measures as multipliers based on the year displayed.

      We assign an annual discount value to each customer [2017 Discount] and [2018 Discount] and multiply that by [Sales] to get an allowance measure.

      So far I have tried to use:


      IF (YEAR(ATTR([Date])) =2017)

      THEN ([2017 Discount])*SUM([Sales])

      ELSEIF   (YEAR(ATTR([Date])) =2018)

      THEN ([2018 Discount])*SUM([Sales])



      But my results are showing all Sales being multiplied by the [2018 Discount], even where Sales dates are in 2017.


      Any suggestions are much appreciated!

      Thank you!