3 Replies Latest reply on Jun 12, 2017 10:20 AM by Pax Gray

    Calculated Field If Function

    Pax Gray

      Sorry for the basic question. I'm new to tableau and need help formatting a function. What I would like is a percentage of the total within a dimension. I want it to go something like this:

      IF the Result is "positive", then calculate positive divided by total. Can Someone help me format this with the order and punctuation of the function?

      Thank you much

        • 1. Re: Calculated Field If Function



          If [Profit] > 0 Then [Profit]/[Total]


          • 2. Re: Calculated Field If Function
            Madhusudhan Khambham

            Hi Pax Gray,


            You cannot do the percent of total for a Dimension field. It will be possible only on the measures.


            Syntax for calculating the percent of Total: Sum(Measure)/total(sum(measure))



            If you have a dimension like Product Name and the measure say Sales. If you would like to calculate the Percent of total for the Product Apple then you can write your calculation like this.


            If ATTR( [Product Name]) = 'Apple' then

            Sum(Sales)/total(sum(sales)) End


            Please let us know, in case you have any further questions.


            Thanks & Regards

            Madhu K

            1 of 1 people found this helpful
            • 3. Re: Calculated Field If Function
              Pax Gray

              I think we almost have it, I'll explain it a little more to see if we can get it right. So I have a dimension and it can be either 'positive' or 'negative'. And I would for it to go something along the lines of:  If it is 'positive', then I want to divide the number of 'positive' records by the total number of records. Not sure if this can be done at all now or not. Any ideas?