6 Replies Latest reply on Aug 24, 2016 6:29 AM by Jonathan Drummey

# Using LOD Include, but find the subcategory name

Hi,

I'm using the LOD include to work out the % of the highest sub category for my category as follows

Sales of Sub Category = {INCLUDE [Sub Category]: sum([Sales])}

% of Largest Sub Category = max([Sales of Sub Category])/sum([Sales])

This works fine and in my Viz I have the category and then show the %.  What I woul also like to reflect is the name for this sub category as well, but can't find how to reflect - so any help appreciated !

Cheers

Mick

• ###### 1. Re: Using LOD Include, but find the subcategory name

Mick,

Try another calculated field that uses your existing one, something like:

IF

{INCLUDE [Sub-Category] : SUM(Sales)} == {EXCLUDE [Sub-Category] : MAX([Sales of Sub Category])}

THEN [Sub-Category]

END

That will allow you to compare the sum of Sales at a Sub-Category level with the Sales for the Max Sub Category and give you the sub-category where the two values are equal.

Hope that helps!

Joshua

• ###### 2. Re: Using LOD Include, but find the subcategory name

Thanks Joshua for the reply.  Have tricked around with that and doesn't generated me the answer

best I can do is when the sub category is the full amount of the category then I can generate the sub category name otherwise I get an *

• ###### 3. Re: Using LOD Include, but find the subcategory name

Hmmm...  works for me, but there may be something I'm not seeing that changes things in your case.  Do you happen to have a sample workbook or even a screenshot of your setup?

-Joshua

• ###### 4. Re: Using LOD Include, but find the subcategory name

1) If you want to read a long post on the subject check out LOD Expression Remix – Finding a Dimension at a Lower Level | Drawing with Numbers.

2) Since LOD expressions are doing separate aggregations than the vizLOD when floating point numbers are involved you can end up with different results, you should either round them or convert to integers prior to doing the comparison. There's a comment on this just before the Conclusion of Bora Beran's fantastic post introducing LODs: What’s new in Tableau 9.0? Part 2 – Level of Detail Expressions « Bora Beran .

Jonathan

• ###### 5. Re: Using LOD Include, but find the subcategory name

cheers Jonathan, i used the first link which included a link to another post and this is effectively the code I used:

ATTR(

{INCLUDE [Sub-Category]:IF SUM([Customer Name])==MAX(

{EXCLUDE [Sub-Category]:MAX(

{INCLUDE [Sub-Category]:SUM([Customer Name])}

)})

THEN MIN([Sub-Category]) END}

)

• ###### 6. Re: Using LOD Include, but find the subcategory name

Awesome!