2 Replies Latest reply on Feb 12, 2012 8:07 AM by David Klass

    Creating calculated fields

    David  Klass

      Hello: I am trying to create a calculated field that uses 2 previously created fields but as I am a new user i cannot finfd the 'secret key' as to how to do this within Tableau itself without retreating to the query that created the .twb file


      Field 1 is a count of 'return less than 5 days' and is the sum in Tableau of


      IF([TimeOutBRDays]/[Number of Records])<5 THEN 1 ELSE 0 END


      Field 2 is COUNT([TimeOutBRDays])


      I would like to create Field 3 :  Field1/Field2*100


      You can see the layout of the crosstab in the inclosed file to get a sense of the structure of the crosstab.


      Thanks for any help with this. David

        • 1. Re: Creating calculated fields
          Alex Kerin

          Difficult to answer without seeing the structure of your data. With that said, the first calculation could be a problem as this is operating at the row level (there's no aggregation - sum, max, etc), so number of records (i.e. rows) will always be 1.


          Maybe try:


          IF([TimeOutBRDays])<5 THEN 1 ELSE 0 END



          and sum([field 1)/sum(field 2)

          Don't multiply by 100 - let Tableau handle this as a percent.


          If that doesn't help, then if you can post some of the data and the 'expected' result from this data, that would really let us see what needs to be done.


          Don't you love the smell of Tableau on a Sunday morning? I need more coffee.

          1 of 1 people found this helpful
          • 2. Re: Creating calculated fields
            David  Klass

            Thanks for the response.  I altered a bit what you suggested and found that the following gave me what I wanted





            The calculated  field: IF([TimeOutBRDays]/[Number of Records])<5 THEN 1 ELSE 0 END was named [Return_5_Days]  and dividing by the calculated field [CountRDate] works with the SUM operator for the row level field.  Thanks again.  David