5 Replies Latest reply on Feb 15, 2016 11:01 PM by Shinichiro Murakami

# Ratios and Aggregates

Hi I am new to using Tableau, I was playing around with the super store data and came up with a doubt. I created a calculated field as [profit]/[sales]. When i pull this calculation into the view, it throws up wrong values. Is that something to do with the default aggregation?

Kindly help me understand this better.

Also in sheet two when I tried calculating sales percentage with the formula [sales]/[TotalSales], Cant mix aggregate and non-aggregate measure pop up. How can this situation be handled.

• ###### 1. Re: Ratios and Aggregates

Yes, it's related to the level of aggregations.

[Calculation1]

sum([Profit])/sum([Sales])

[Sales Percentage]

sum([Sales])/[Total Sales]*100

///  10 / 100  :  20 / 40

///  (10+20) / (100+40) [sum([Profit])/sum([Sales])]

is different from (10/100) + (20/40)  [sum([Profit]/[Sales])]

Thanks,

Shin

• ###### 2. Re: Ratios and Aggregates

The first part worked fine. The sales percentage calculation gives wrong values

[Sales Percentage]

sum([Sales])/[Total Sales]*100

The [TotalSales] is a calculated field with calculation sum([sales]) in it. So all the fields show 100 with the sales percentage calculation above.

• ###### 3. Re: Ratios and Aggregates

Gowtham,

Put calculated field as below.

[Sales Percentage]  //  Overview: Level of Detail Expressions

sum([Sales])/attr({fixed :[Total Sales]})*100

Thanks,

Shin

1 of 1 people found this helpful
• ###### 4. Re: Ratios and Aggregates

Thank you this is what I was looking for.  Should make myself comfortable with the LOD calculations..!!

• ###### 5. Re: Ratios and Aggregates

It seems something difficult at the first impression, but soon becomes very useful, I can bet .

Thanks,

Shin