4 Replies Latest reply on Aug 14, 2019 2:58 AM by Christoph Klavehn

    Transposing calculations in Tableau

    Christoph Klavehn

      Dear Community,

      A (potentially) simple issue I am struggling with:


      I have the attached view that shows the number of countries that received votes from a selected (filter) other country in a survey. In the image below the view shows the votes by respondents from Austria.




      I wonder how I can display the “reverse” perspective, ie to show the votes Austria (or any other selected country) received form all other countries that voted for it.
      I think this will require switching from calculating along rows to columns. See the highlighted image.



      Is this possible within Tableau? Perhaps an alternative might be first create a new data source that has everything transposed?

      Many thanks for any clues!



        • 1. Re: Transposing calculations in Tableau
          Paul Wachtler

          Hi Christoph,


          In your crosstab, your % of total table calc is set to use table across.  This works with your first map since you're selecting a country and seeing all the response values.  In your second version, you want to select a response and see all of the country values.  To do that, you first need to set the table calculation to calculate using table down.  Here's what the updated crosstab looks like (it's called cross table down in the attached workbook).


          Screen Shot 2019-08-02 at 11.28.40 AM.png


          Now you can create a map off of the Country lat and long coordinates instead of the Response coordinates and switch the Country field with Response in the filter shelf.  So when you select a Response country you'll see the percentages for all of the countries.  This is on map (2) in the attached workbook.


          Screen Shot 2019-08-02 at 11.33.00 AM.png




          1 of 1 people found this helpful
          • 2. Re: Transposing calculations in Tableau
            Christoph Klavehn

            Hi Paul,

            thanks for sharing your advice!


            To stick with Austria as an example, following the ‘table down’ approach will yield the share of votes to Austria (of all votes that Austria received, ie ‘table down’, as in your table image).
            However, what I would like to show in the view is the share of votes each country gave to Austria (of all votes each country gave). Sorry that this was not clear from my initial post!


            The goal is to compare results between countries, ie for every row I’d like to see the results for the country selected (the highlighted column for Austria in the image below).crosstab.PNG


            The result from the table with ‘table across’ has all the correct numbers, I only need a way to display them by column (as in the highlight). Perhaps this calls for a new calculated field?


            Any ideas are welcome! Many thanks again, Chris

            • 3. Re: Transposing calculations in Tableau
              Anuj yadav

              If I understand your question right, you can use below approach


              Create a parameter to toggle between response to and response from.


              create calculate field Counrty_Calc which would be something like this


              if Parameter = ‘Response To’ then [Response to Country ]

              else [Response from Country]



              Place the Country_Calc over your Country pill.

              • 4. Re: Transposing calculations in Tableau
                Christoph Klavehn

                Thanks much to both of you, Paul Wachtler and Anuj Yadav for the helpful inspiration.


                I managed to do what I wanted with the below LOD:

                The result is a 'table across by column' (if that makes sense) for the country selected in the filter. A parameter can now be set to change between votes "by" a country vs. votes "to" a country.


                Workbook attached. Thanks again for your help!