1 Reply Latest reply on Aug 23, 2013 3:57 AM by Dana Withers

    If statements conditional on multiple filter selection


      Hi, I am new to tableau and I am having trouble creating a metric which responds to multiple filter selections.


      Firstly my data is formatted as follows:


      DateChannel Metricvalue
      week 1Channel 1Metric 1100
      week 1Channel 1Metric 2200
      week 1Channel 1Metric 3300
      week 1Channel 1Metric 4300
      week 2Channel 1Metric 1400
      week 2Channel 1Metric 2500
      week 2Channel 1Metric 3500


      The idea being that i am able filter for any given week any channel and metric combination via filter.


      However I want to be able to perform a calculation if two metrics are selected. So far all tableau is doing is summing the value for the metrics.


      I have tried to do this via a calculated filed using the following:


      If [Metric] = "Metric 1" and "Metric 2" then (value/2)

      else value



      I have also tried nested if statements but it still just sums the two values.


      I don't know if my data is in the correct format or if there is an error in the calculations. Please Help?



        • 1. Re: If statements conditional on multiple filter selection
          Dana Withers



          The thing to bear in mind with Tableau's calculations is that they have to make sense on a row level before they're taken forward to summarised levels.

          If you use an if to see if a metric is 1 and 2, it won't make sense on a row level because it can never be 1 and 2 on any row. So on your row level, the IF always comes out at the ELSE bit.


          From your if statement though, it looks like you're trying to do an average?

          Why not use average in your calculation? Average on one metric is the value of that metric and otherwise it is averaged.


          Hope that helps.