7 Replies Latest reply on Nov 13, 2017 1:19 AM by Simon Runc

    Clustered Bar graph with multiple measures

    keerthana kumar

      I am creating side by side bar graph showing multiple measure. How can i reduce gap between the graphs and display as clustered bars with no gaps in between:

      have refer below links but not sure how to handle different Measures.

      Creation of a Grouped Bar Chart | Tableau Software

      https://vizpainter.com/1-easy-trick-for-clustered-bar-charts/

       

      OUTPUT:

       

      MY OUTPUT.PNG

       

      EXPECTED OUTPUT:

      chart 1.PNGlegend 1.PNG

        • 1. Re: Clustered Bar graph with multiple measures
          Simon Runc

          Hi keerthana,

           

          So this isn't an easy one. The trick from VizPainter relies on the bars being formed via a dimension (customer in that example). This means that the index() calculation can run over this dimension. Measure Names is a pseudo dimension, in that it can't be partitioned over.

           

          No perfect, but this might suffice....

           

          I've built the chart as normal, but then have added in a MIN(1.0) dimension on rows. I then set the axis range to 0.5 to 1.5, and set the size to Fixed and 1 and centred

           

           

          This controls how wide the bars are...however this doesn't leave any space between each category. To do this I set the pane lines as per the below

           

           

          Hope that helps

          1 of 1 people found this helpful
          • 2. Re: Clustered Bar graph with multiple measures
            Sankarmagesh Rajan

            Hi Keerthana,

             

            Create query

            SELECT [Orders].[Category] AS [Category],

              [Orders].[Discount] AS [Discount],

              [Orders].[OrderDate] AS [OrderDate],

              [Orders].[Profit] AS [Profit],

              [Orders].[Quantity] AS [Quantity],

              [Orders].[Region] AS [Region],

              [Orders].[Sales] AS [Sales],

              [Orders].[Segment] AS [Segment],

              [Orders].[ShipMode] AS [ShipMode],

              [Orders].[StatePro] AS [StatePro],

              [Orders].[SubCategory] AS [SubCategory],

            sum([Orders].[Sales]) as DataValue,'Sales' as Saledata, 'Bar' as [Marktype]

            FROM [dbo].[Orders] [Orders]

            group by [Category],[OrderDate],[Region],[Segment],[ShipMode],[SubCategory],[Discount],[Profit],[Quantity],[Sales],[StatePro]

             

            union All

            SELECT [Orders].[Category] AS [Category],

              [Orders].[Discount] AS [Discount],

              [Orders].[OrderDate] AS [OrderDate],

              [Orders].[Profit] AS [Profit],

              [Orders].[Quantity] AS [Quantity],

              [Orders].[Region] AS [Region],

              [Orders].[Sales] AS [Sales],

              [Orders].[Segment] AS [Segment],

              [Orders].[ShipMode] AS [ShipMode],

              [Orders].[StatePro] AS [StatePro],

              [Orders].[SubCategory] AS [SubCategory],

            sum([Orders].[Profit]) as DataValue,'Profit' as Saledata,  'Line' as [Marktype]

            FROM [dbo].[Orders] [Orders]

            group by [Category],[OrderDate],[Region],[Segment],[ShipMode],[SubCategory],[Discount],[Profit],[Quantity],[Sales],[StatePro]

             

            Create calculation bar position with measure name.

             

            Refer attached workbook.

             

            Thanks

            sankar

            2 of 2 people found this helpful
            • 3. Re: Clustered Bar graph with multiple measures
              keerthana kumar

              Thanks Simon ,

              The trick is definitely helped. But in cases where i chose Month of Date as Dimension.

              As there is no space between months .there less clarity in reading / the objective of this chart type is lost.

               

              bar graph1.PNG

               

              sample.PNG

              • 4. Re: Clustered Bar graph with multiple measures
                Simon Runc

                Thanks Shawn,

                ...it's actually Simon!!

                 

                So on my initial version, if you add another dimension (such as Month) you just need to move the Borders level on by one;

                 

                 

                however if you have lots of bars (quite densely packed) you'll barely notice the space (unfortunately I've set it to the maximum line weight in this option). So if this case you could try just adding a "dummy" measure and set it to white. Option 2 tab shows this.

                 

                Or the data-reshaping option, shown by Sankarmagesh, means that Measure Names (created by yourself, not Tableau) is a real dimension, so the Viz Painter technique will work (as we can partition index() over this).

                 

                Hopefully one of those will work for you.

                1 of 1 people found this helpful
                • 5. Re: Clustered Bar graph with multiple measures
                  keerthana kumar

                  Thanks Shankar !! i have worked on your solution as well i was able to get the gap between the graphs. except the pain of writing query and reshaping it.

                  Thanks for the solution.

                  • 6. Re: Clustered Bar graph with multiple measures
                    keerthana kumar

                    Thanks again Simon!!

                    wish i could mark both your answers correct.

                    Spacing is now sorted. Color Legends i had to place an Screenshot image. Just to hide dummy measure.

                    It would have been great if i could get the headers at the bottom of the graph.

                    • 7. Re: Clustered Bar graph with multiple measures
                      Simon Runc

                      Yes it would be nice to be able to "manually amend the legend entries"...your solution is one I've used many times (also as Tableau legends aren't always that nice!), but on the attached is another method (using a sheet as legend).

                       

                      With regards the labels to the bottom, again would be nice to have this option! If you don't need scroll bars, you can set the headers up on a separate sheet and put together in a dashboard. Again I've done this in the attached (with a hover action to help the user see what they are looking at).

                       

                      Hope these help.

                      1 of 1 people found this helpful