0
votes

I have data like this:

enter image description here

For each variable, there is "category" variable associated with it. the categories for values in a variable are good, bad or missing.

I want to make a stacked bar plot such that, each variable (not including the associated category variable) represents a bar and within a bar, the 3 categories(stacked) show as percentage. Like the image below.

Preferably if you right click each bar and select "view data" option, you can visually examine the data table, to check which value or which row is bad or good.

enter image description here

1

1 Answers

0
votes

This is easy to do in Tableau. Using Superstore (the sample data set that comes with the product)...

  1. Bring Sales onto the rows shelf
  2. Bring Category to the columns shelf
  3. Put Ship Mode on the Color Marks Card
  4. On the Sum(Sales) pill in the Rows shelf, right click, select quick table calculation -> percent of total
  5. Click on the same pill and select compute using Ship Mode

Table Calculations

Compute using ship mode

Final Picture

I'm not 100% sure I understand your exact data set but you would need to just substitute your objects for the ones that are detailed above.

As far as your specific data, it is in a hard format to work with. What Tableau really wants is something like:

cat     var value
----------------------
num     foo bad
num     bar bad
num     1   good
num     2   good
num     3   good
num     .   missing
char    b   good
char    1   bad
char    a   good
char    v   good
char    2   bad
char        missing

There are tools like Tableau Prep that can do this. But if you can put the data in this format it will be much easier to consume in (any) reporting tool. This is a type of pivot but you need to pivot each combination of cat/value and then union it with all other cat/value pairs.