3 Replies Latest reply on Apr 27, 2019 8:22 AM by Jonathan Drummey

# Calculating a proper Gini Coefficient as an LOD(?)

I've been trying to recreate the solution for calculating a Gini Coefficient as suggested here - Gini Coefficient .

However, what I really need is to calculate the Gini value for members of a dimension.  Rather than the solution proposed above which calculates the Gini across all members of the dimension shown, I'd like a discrete value for each member.

For example, the post cited above produced the following (I get different values in the current version of Superstore).

What I really need to do is calculate the seperate Gini Coefficient  for each member of the dimension (Envelopes, Office Furnishings, etc.) without showing the underlying constituents.

What I'm headed to is an analysis comparing Gini Coefficients of different things.  (E.g., comparing the inequality of sales by number of orders for Envelopes vs. Office Furnishings, etc.)

Any help would be greatly appreciated!  Many thanks to the community!

• ###### 1. Re: Calculating a proper Gini Coefficient as an LOD(?)

Hi Paul,

The Gini coefficient formula requires some sort of index or ranking (the i term in the formula) and the only way to do that natively in Tableau is to use a table calculation. Table calculations compute over the dimensions in the view (not the underlying data),  so what you'd need to do is bring a lower-level dimension like Product Name in the view (i.e. computing the Gini coefficient of products within each sub-category), set the compute using to that lower level dimension, and then because the view would have a dimension you don't want and a bunch of extra marks then you'd use a table calculation like INDEX() or FIRST() with the filter set to 1 or 0, respectively, to filter out the extra marks (after the Gini coefficient is applied).

Jonathan

1 of 1 people found this helpful
• ###### 2. Re: Calculating a proper Gini Coefficient as an LOD(?)

Thanks for the explanation.

You, Sir, are definitely a generator of good karma in this world!

Cheers!

• ###### 3. Re: Calculating a proper Gini Coefficient as an LOD(?)

Thank you!