4 Replies Latest reply on Mar 21, 2017 10:51 AM by Sandhya Samboju

Hello,

I have a business requirement where I need to add an additional bar in my bar chart.

contract segment is a  calculated filed, Business needs an additional bar by combining the Total Fleet and Total Small business. is this something we can achieve in tableau. any ideas.

Attaching the Calculation for contract segment.

Thank you,

Sandhya.

Good morning

I looked at the calculation and you could do it that way or you could use something like {fixed: sum([acquisition a...])}

You may need to play with that if you have other filters in the view

Let me know if that helps

Jim

Hi Jim

Good Morning!!

Thank you for the response

I am kind a playing around I tried creating a set for the Contract segment and add subtotals .. But I am trying to see if there is any possibility of removing the Sub total for "Total Van " Bucket..

Sandhya,

From your screenshot, I gather that the various line items are based on a dimension called [Zz_Contract Segment]. Consequently, there are 2 ways you can deal with this, given the structure of your data:

Method 1: Subtotals

To leverage Tableau's subtotals, you will need to create a calculated field to define a level of organization above [Zz_Contract Segment]. We'll call it [Segment Section]:

[Segment Section]

```CASE [Zz_Contract Segment]
WHEN 'Total Fleet' THEN 1
WHEN 'Total Small Business' THEN 1
ELSE 2
END
```

Put this calculated field on your Rows shelf, to the left of [Zz_Contract Segment]. Turn on Subtotals, then turn off Show Headers.

The result looks something like this (using Superstore and the [Segment] field as an example). Note that when Subtotals are turned on, they're turned on for all sections, so the third entry has a subtotal all to itself. I'm not aware of a way to override this behavior, but if you can tolerate an extra gratuitous subtotal line in your chart, this technique will work for you.

Method 2: LOD Expressions

You can use LOD expressions to allow you to rewrite your view using Measure Names / Measure Values to drive your rows and bars. Something like this:

[Total Fleet]

{ FIXED : SUM(IF [Zz_Contract Segment] = 'Total Fleet' THEN [Acquisition A] END) }

{ FIXED : SUM(IF [Zz_Contract Segment] = 'Total Small Business' THEN [Acquisition A] END) }

{ FIXED : SUM(IF [Zz_Contract Segment] = 'Total Fleet' OR [Zz_Contract Segment] = 'Total Small Business' THEN [Acquisition A] END) }

[Total Van]

{ FIXED : SUM(IF [Zz_Contract Segment] = 'Total Van' THEN [Acquisition A] END) }

If you do this, you will also have to do your own [Grand Total] calculation, because otherwise the automatic Grand Total will include your [Total Fleet + Small Business] subtotal.

The result looks something like this (again, using Superstore and [Segment] as an example):

Workbook with Superstore examples attached (version 10.1.5)

1 of 1 people found this helpful