1 Reply Latest reply on Dec 28, 2016 1:42 AM by TEG Data Viz-ard

    How to use the values of Dimension in Calculation field?

    Nagaraj Ganiga



           I'm new to Tableau so Please let me know if I have to correct myself anywhere.


           Now the actual problem, as you know in the sample superstore Region is one of the dimensions which contains following values Central, East, North, West. And Sales is one of the measures, considering those two I need a view in which I want the "Sales of Central" along with that I want to see the "Sales of Central - Sales of one of the other values(East or North or West which I have to select)".


      Example:    Region          Sales

                         Central           10

                         East                15

                         North              20

                         West               25


      Now in view  when Select "West" out of East, North and West

      I should see 

                              Central          Central-West

                                 10                   -15



      Please let me know If need to be more specific.

      Thank you.

        • 1. Re: How to use the values of Dimension in Calculation field?
          TEG Data Viz-ard

          Hi Nagaraj,


          I hope i understood your ask properly. I've tried to recreate the table you had asked for. Based on the parameter on the right, 'Region Select' the Sales1 column picks up the sales of that particular region and the last column gives you the difference. For example, in this case, Central region has 2.9MM sales, East has 8.3 MM; hence the difference is -5.3 MM.



          How did i do this?


          1. I created a parameter to choose region

          2. Create a Calculated field ' Sales 1' - this creates another column 'Sales 1' in the dataset and assigns the Sales value if the IF condition is satisfied (the region and the region parameter has the same value); else it assigns the value of 0 to the Sales 1 column.


          In order to use this value for all the regions, you can use LOD 'Exclude' - this will exclude the Region column while performing the calculation


          3. Create another calculation - SUM([Sales]) - sum([Sales1]) and drag this as the last column


          Here you go!!

          2 of 2 people found this helpful