1 2 Previous Next 25 Replies Latest reply on Apr 16, 2014 6:10 AM by juliette.mccormack

# dynamic group in pie chart

I have a table with the follow data.

country     %sales

A               35

B               30

C               15

D               5

E               5

F               5

G               5

I need group in a part of the pie all % less or equal that 5.  Example.

country     %sales

A               35

B               30

C               15

X               20

I try with sets and parameters, but only works with bars, not with pie chart.

Luis E.

• ###### 1. Re: dynamic group in pie chart

If you create a static group on Country, where D, E, F, and G are grouped to "X", will you get the results you're looking for?  Problem with this is it is not dynamic, so if you have more countries later, they won't be added to "X" based on the criteria you've specified.  There may be a better approach.

• ###### 2. Re: dynamic group in pie chart

Luis,

Would a calculated group not work?  Something like:

IF [% Sales] < .05 THEN "X"

ELSE [Country]

END

I'm not sure if the table in your post is the underlying data or the results in your view.  So the calculation may need adjustment.  I'm also not certain why a Set would work with bar charts but not pie charts -- can you be more specific?

Regards,

Joshua

• ###### 3. Re: dynamic group in pie chart

Matthew, thanks for your answer, but I need the group dynamic for all countries with % less that 5%, if tomorrow I have more countries with % les 5%, I need group this countries.

country     %sales

A               25

B               20

C               15

I                15

X               25

X = D 5% + E 5% + F 5% + G 5% + H 5%

Country I is new with % great 5%, and H is new but less or equal 5% and is part of the group X.

• ###### 4. Re: dynamic group in pie chart

Then Joshua's solution would be my next suggestion.

• ###### 5. Re: dynamic group in pie chart

Joshua, thank for your answer.  I try this calculate field with the % dynamic, but doesn't works.  I'll try with the constant 0.5.

• ###### 6. Re: dynamic group in pie chart

Luis,

Either the parameter or the constant should behave the same, so I'm guessing there may be something else going on.  It would greatly helpMatthew Lutton, me, and anyone else trying to help if you could post a packaged workbook (.twbx) using mockup data if necessary.  Second-best would be a few screenshots to help us see what errors you are getting.

Regards,

Joshua

• ###### 7. Re: dynamic group in pie chart

Joshua,

I attach the real problem, with MCC (merchant categories code).  I need the MCC % participation and group all MCC's that are less or equal N.

In the packaged workbook, I have 3 examples:

- % MCC.  My base chart.

- Top N MCC. Chart with Top N MCC's

- % Participation MCC dosen't works.  I need the % participation dynamic, like the last one (top n mcc) but with the %.

I try with the calculated field with the % but, present a error.

Regards,

Luis E.

• ###### 8. Re: dynamic group in pie chart

Luis,

Thank you for the workbook.  Would you please extract the data and repost?  When I try to open it, it asks for your credentials.  Even if I had them (which wouldn't be good ) I wouldn't be able to connect to your database.  Thanks!

Regards,

Joshua

• ###### 9. Re: dynamic group in pie chart

Joshua,

Sorry, in this moment I attach the files.

• ###### 10. Re: dynamic group in pie chart

Morning all,

I have a similar problem to the above where I wish to "group" everything with a value of 1 or less as Others dynamically.

I have tried to achieve this by;

IF [Number of Records] < 2 then "Others"

ELSE [Product Name]

END

However this causes all values to be returned as Others (I assume it is counting the cell value rather than the calculated total.

IF sum([Number of Records]) < 2 then "Others"

ELSE [Product Name]

END

Does not work either and gives an aggregation error (I assume because Tableau does not know what the value is aggregating against).

Attached is an extract hopefully explaining this a bit more clearly.

• ###### 11. Re: dynamic group in pie chart

Hi Anthony

Try:

IF SUM([Number of Records])>1 THEN ATTR([Product Name])

ELSE 'Other'

END

BW

Juliette

• ###### 12. Re: dynamic group in pie chart

Hi Luis,

find the attached solution.

• ###### 13. Re: dynamic group in pie chart

Thanks Juliette,

This converts the dimension to a measure and does not actually seem to split the data (see attached).

Prakesh's example does not work in my situaiton because the data is already aggregated in his example.

Jonathan Drummey 's example Create an "other" field based on a dynamic calculation got me most of the way there but is for percentages rather than pure numbers and resulted in my pie chart having multiple segments in the "Others" section (the different parts lost me a bit to be honest!) rather than an amalgamated value as Jonathan achieved with his pie chart.

• ###### 14. Re: dynamic group in pie chart

It completely skipped me by that your ultimate goal was to put it into a pie chart!  Sorry.

I think Jonathan has calculated the percentages from the sales figures so that they can be used to plot on the pie.  His pie has 7 marks - one mark for each slice - and yours has a 257 marks - one for each product.  I've managed to recreate the fields he has done but with Product Name (instead of State) and Total Records (instead of Total Sales).  The 'Table' sheet shows the calculations for this and the 'Pie' shows the result - one block for all the 'other' products.

HOWEVER.... what I can't seem to be able to do is to put the 'Product Name w/Other' calculation on Colour - I get an error message about not finding the percentages.  But the percentages are there for it as shown in the 'Table' sheet so why can't it use it?

Perhaps someone can shed some light?

Sorry I couldn't finish it Anthony.

Best wishes

Juliette

1 2 Previous Next