3 Replies Latest reply on Jun 21, 2016 11:03 PM by Lian Norliansyah

# Calculate % difference of two members

Hi,

I would like to calculate % ticket delivered on time based on the following example below:

in which it should be calculated as "Ticket Delivered On Time" / "Total Ticket" = 90% (based on the sample below)

DateGroupL1 TeamL2 TeamGroup TypeBUServiceMetric NameValue
1/05/2016Group A1Team ATeam AAPrimaryNo BUNo ServiceTotal Ticket10
1/05/2016Group A1Team ATeam AAPrimaryNo BUNo ServiceTicket Delivered On Time9

I need help how can this be achieved in Tableau.

I can achieve the result by using table calculation:

- Calculation Type: Percent From

- Calculate the percentage along: Metric Name

- Display the value as a percentage of: Next

Then I hide one of the Metric.

(see attached example)

However, I would like to use a calculation within Tableau, which will give a greater flexibility in the presentation of the data.

If the data source is OLAP, I can calculate using MDX, however, the source is SQL server table.

Thanks,

Lian

• ###### 1. Re: Calculate % difference of two members

Hi Lian,

It seems you already have a good knowledge about the Tableau table calculations. A little trick I discovered is that you can dragged out your table calculations to the measure data pane. See below:

I can now rename the table calculation and make it a calculated field:

I find it super useful, it's also really convenient when you want to perform some calculations you know tableau can do, without taking the time/ risk to type them yourself!

Hope this helps,

• ###### 2. Re: Calculate % difference of two members

you can also use them then in parameters to allow the end user to swap between the different table calcs in the visualization

• ###### 3. Re: Calculate % difference of two members

Hi Stephane,

The use something like SUM([SALES]) / TOTAL(SUM([SALES])) does not work on the sample

I provided.

If I use the above logic, the TOTAL(SUM([SALES])) would be Total Ticket (10) + Ticket Delivered On Time (9) = 19.

So % of Total for Ticket Delivered On Time = 9 / 19, which it should be 9/10

Is there any other calculation I can use?

Thanks,

Lian