2 Replies Latest reply on Sep 20, 2019 12:20 PM by madhuri.tanniru

# Tableau Calculation based on Dimension Value

Hi!

I am trying to create a measure that gives me a value based on the dimension. Below is a screenshot of the table which has details of the spend generated by 2 business types, I want to show another column that has % of total spend.

I tried the below case statement but it doesn't seem to work. My final table should just show the type of business, revenue and the % of total. For the first type I want it to divide (spend for small business)/ total spend, for the second it has to take (spend for large business)/total spend and so on all for type.

CASE [Type]

WHEN 'Small business' then [Small Busines Indicator]/[totalspend]

WHEN 'Large busines Indicator' then [Large Busines Indicator]/[totalspend]

end

Shreyasi

• ###### 1. Re: Tableau Calculation based on Dimension Value

SUM([Whole Dollars]) / TOTAL(SUM([Whole Dollars]))

• ###### 2. Re: Tableau Calculation based on Dimension Value

Hi Shreyasi,

There are a couple of ways you might approach this.  One would be to use a table calculation.  It might be as simple as adding a quick table calculation from the drop down on the field:

Another approach would be to use a Level of Detail (LOD) calculation.  Code like this:

SUM([totalspend] / SUM({EXCLUDE [Type] : SUM(totalspend)})

might also work.  That takes the SUM of the value for each slice of data (Type) and then divides by the total (where Type is excluded from slicing the data).

Hope that helps a bit!

Joshua