Hi, how can I get the calculation for below conditions,

1) Type A,B,C = each/ total for a,b,c

2) Type D =  D / Grand Total

How to do this?
Jun 6, 2019 in Tableau 220 views

Use the calculated column to calculate the sum of sales for a, b, c like below

Sales_a_b_c = IF [Type] = "A" OR [Type] = "B" OR [Type] = "C" THEN [Sales] ELSE 0 END

Now To calculate calculation for each type

IF [Type] = "A"  THEN SUM([Sales]) / SUM([Sales_a_b_c])

ELSEIF [Type] = "B" THEN SUM([Sales]) / SUM([Sales_a_b_c])

ELSEIF [Type] = "C" THEN SUM([Sales]) / SUM([Sales_a_b_c])

ELSE [Sales] / { SUM([Sales]) }

END

Try the above, hope it helps!
• 32,930 points

How to divide one measure by another?

Yes it is possible, Option 1: Create a calculated ...READ MORE

Divide count of Table 1 by count of Table 2 on the same time interval

Use a custom SQL to create a ...READ MORE

Want to hide the Bar for Grand Total in the bar chart in Tableau

Tableau treats the whole visualization uniformly.  If you ...READ MORE

How to color code cells of a column based on the text value in Tableau

You can use the following steps to ...READ MORE

+1 vote

Calculated filed with if-then

Below is the required code:  IF (NOT ISNULL([test2])) ...READ MORE

How can I download tableau workbook with its data from tableau server?

In essence, no. Since the workbook is ...READ MORE