1
votes

I am trying to create a plot similar to those created by Google's ngram viewer. I have the ngrams that correspond to year, but some years have much more data than others; as a result, plotting from absolute counts doesn't get me the information I want. I'd like to normalize it so that I get the counts as a percentage of the total samples for that year.

I've found ways to normalize data to ranges in Tableau, but nothing about normalizing by count. I also see that there is a count distinct function, but that doesn't appear to do what I want.

How can I do this in Tableau?

Thanks in advance for your help!

Edit: Here is some toy data and the desired output.

Toy Data:

+---------+------+
| Pattern | Year |
+---------+------+
| a       |    1 |
| a       |    1 |
| a       |    1 |
| b       |    1 |
| b       |    1 |
| b       |    1 |
| a       |    2 |
| b       |    2 |
| a       |    3 |
| b       |    4 |
+---------+------+

Desired Output: Screenshot 2017-04-26 12.39.36.png

1
Why not just create a function that sums the values you want and divides by the period total? - matt_black
plot the absolute counts, and then right click on your measure field and choose quick table calcs, pick % of total. then experiment with the "compute using" setting via right click as also - Alex Blakemore
P.S. People can give you better assistance on SO if you post a little sample data along with a very precise question - Alex Blakemore
Thanks for the feedback @AlexBlakemore. I've updated the post with toy data and a mockup of the desired output. - Alex Hall

1 Answers

2
votes

Put [Year] on the Columns shelf, and if it is really a Date field instead of a number - choose any truncation level you'd like or choose exact date. Make sure to treat it as a discrete dimension field (the pill should be blue)

Put [Number of Records] on the Rows shelf. Should be a continuous measure, i.e. SUM([Number of Records])

Put Pattern on the Color shelf.

At this point, you should be looking at a graph raw counts. To convert them to percentages, right click on the [Number of Records] field on the Rows shelf, and choose Quick Table Calc->Percent of Total. Finally, right click on [Number of Records] a second time, and choose Compute Using->Pattern.

You might want to sort the patterns. One easy way is to just drag them in the color legend.

enter image description here