3 Replies Latest reply on Jul 13, 2016 7:09 AM by Tom W

    Creating side-by-side  & stacked bar chart with two

    Baji Bonam

      I am trying to achieve the chart as in the attached mock-up.

       

      To summarize - I am comparing the sales of a given country and its corresponding region (at both country and region level) for each of the years.

       

      Now I would like to have a side-by-side and stacked bar charts of the country and its corresponding region for each of the years. I have tried various options of structuring the data to achieve the desired outcome, but seems to be facing issues with one aspect or the other. The main challenge I have is from 2 perspectives - (a) filtering data by a given country e.g. f I select a different country say France then this chart should show 'France' and 'EMEA'  combination (b) It should also restrict users  data based on the login. If EMEA region head logs in s/he shall be able to see 'France' and 'EMEA' by default

       

      I am flexible with the data model to be used or tableau workarounds to achieve it. Can you please suggest the best way to get this output.

       

      Many thanks in advance.

        • 1. Re: Creating side-by-side  & stacked bar chart with two
          Tom W

          This is difficult because a filter on 'India' would exclude all other countries in the APAC region. You might be able to do this with a Level of Detail calculation, but it will depend on the structure of your data and what's available.

           

          Please attach a Tableau Packaged Workbook.

          • 2. Re: Creating side-by-side  & stacked bar chart with two
            Baji Bonam

            Thanks Tom.

             

            I have implemented it successfully with the data model changes. At a high level - it is to have both 'country' and 'region' in one column - for each set of values we need to display on the chart.

            See values in 'hierarchy' column,  this field is displayed on the chart, whereas when we select 'D1' from 'filter column' it now displays both 'D1' and its corresponding region 'R1'.

             

            The key is to aggregate the data in this format.

                   

            filter columntypehierarchydealercountryregionloyalityscoreYEAR
            D1DealerD1D1C1R1L1302010
            D1DealerD1D1C1R1L2202010
            D1DealerD1D1C1R1L3502010
            D1DealerD1D1C1R1L1202011
            D1DealerD1D1C1R1L2502011
            D1DealerD1D1C1R1L3302011
            D1RegionR1D1C1R1L1302010
            D1RegionR1D1C1R1L2202010
            D1RegionR1D1C1R1L3502010
            D1RegionR1D1C1R1L1202011
            D1RegionR1D1C1R1L2502011
            D1RegionR1D1C1R1L3302011
            • 3. Re: Creating side-by-side  & stacked bar chart with two
              Tom W

                  Generally I achieve this by having the two different 'Geography' options in the same column. I.e. a data structure as below. The problem with the way your data is structured is that you're trying to show two different dimensions as if they are the same dimension.

               

              YearGeographyMetricValue
              2010IndiaRed69
              2011IndiaRed12
              2012IndiaRed93
              2010APACRed9
              2011APACRed83
              2012APACRed83
              2010IndiaYellow85
              2011IndiaYellow57
              2012IndiaYellow27
              2010APACYellow88
              2011APACYellow87
              2012APACYellow92
              2010IndiaGreen42
              2011IndiaGreen58
              2012IndiaGreen56
              2010APACGreen89
              2011APACGreen69
              2012APACGreen59

               

              I'm not sure if you're familiar with SQL or not, but I normally create a dataset like above by using a UNION statement to fetch the two differently levels of aggregation.

               

              I've also attached a Tableau Packaged Workbook (Tableau 9.3) to demonstrate how it works once you've got it in Tablau.

              1 of 1 people found this helpful