4 Replies Latest reply on Oct 16, 2017 10:52 AM by Branden Kornell

# Subtotals for selected field

I am trying to get subtotals for a certain product type. On my rows, I have:

Line of Business |      Employee |      Product |            Sold

ABC                            J. Smith          Apples                4
Bananas            10

Oranges             3

S.Smith          Blueberries          5
XYZ                            J. Doe              Bananas            10

Oranges             5

S. Doe             Oranges              2

J. Jones            Apples               4

I have a grand total for all products sold, but how would I get the subtotal for each product type? I tried creating a Calculated Field and then Compute Using, but selecting Product for that didn't seem to work right. I was also able to do subtotals by Line of Business by right clicking the pill, but I need just totals by product. Any ideas? TIA!

• ###### 2. Re: Subtotals for selected field

That only gives me the totals by employee, rather than by product type. Is there another step I'm missing?

• ###### 3. Re: Subtotals for selected field

Well, from sample data you provided, Product is the lowest level in the hierarchy, so there are no child rows to subtotal. If you added another dimension below product, then Product would subtotal.

• ###### 4. Re: Subtotals for selected field

There are at least two ways to do this: a table calculation or an LOD expression.

Table Calculation:

Here you want to get the subtotal by grouping dimensions differently. The formula is

total(sum([Sold]))

You would create this calculation, and then change Default Tableau Calculation to

Partitioning: Product

Level of Detail Expression:

Here, you want to get the subtotal by excluding certain dimensions from the calculation.

{EXCLUDE [Line of Business], [Employee] : sum([Sold]) }

I'll attach a workbook so you can look at/play with these two calculations.