1 Reply Latest reply on Jan 15, 2015 12:23 AM by Mark Fraser

    Table Calculation

    Andrew Lemon

      Hello Tableau Forum,

       

      I'm stuck trying to write a simple table calculation

      Below is a mock data set. What I'm trying to find is the percentage of apples that are red, which should equal 75% (3/4)

       

      FruitTYPE
      APPLESRED
      APPLESRED
      APPLESGREEN
      APPLESRED
      ORANGESNAVAL
      ORANGESNAVAL
      GRAPERED
      GRAPEGREEN
      BANANAORGANIC
      BANANAORGANIC

       

       

      I wrote the following table calculation but cannot figure out why it does not work. Can someone take a look?

      IF ATTR([Fruit])="APPLES" AND ATTR([TYPE])="RED"  THEN COUNT(TYPE]) / TOTAL(COUNT([TYPE)])) END

       

      Thanks for the assistance!