10 Replies Latest reply on Oct 9, 2014 11:58 AM by Matt Lutton

# Use number of records as a dimension

Hello and thanks in advance for the help. New Tableau user here.

Data:

PlayerBooth Played
ABooth 1
ABooth 1
BBooth 1
ABooth 2
BBooth 2
CBooth 1
ABooth 1
CBooth 2

Intended output:

Times PlayedBooth 1Booth 2
123
200
310

I didnt expect this would be too hard, but I cant figure out how to create the intended output. I have tried using the 'number of records' measure to no avail. What am I missing?

• ###### 1. Re: Use number of records as a dimension

try COUNT([number of records])  (I think SUM() would work too.)

• ###### 2. Re: Use number of records as a dimension

using sum(), the resulting calculated field cannot be used as a dimension, and thus cannot produce the "Times Played" column in the intended output.

• ###### 3. Re: Use number of records as a dimension

Post a sample packaged workbook.

• ###### 4. Re: Use number of records as a dimension

Attached!

• ###### 5. Re: Use number of records as a dimension

And what are you trying to add to this viz?  Total number that "a" was played across all booths (and "b" and "c")?  Or total number of plays at booth-1, booth-2, booth-3?  (And where do you want to see it?)

• ###### 6. Re: Use number of records as a dimension

For each booth, I want to know how many players played the booth, by how many times they played it. This would be a new viz, not an addition to the one in the twbx

based on the data in the packaged workbook, I'm trying to get the following viz:

Times PlayedBooth 1Booth 2Booth 3
0001
1132
2100
3100

verbally:

For Booth 1:

Zero players never played it

One player played it once (Player C)

One player played it twice (Player B)

One player played it thrice (Player A)

For Booth 2:

Zero players never played it

Three players played it once (Players A,B,C)

Zero players played it twice

Zero players played it thrice

For Booth 3:

One player never played it (Player B)

Two player played it once (Players A,C)

Zero players played it twice

Zero players played it thrice

• ###### 7. Re: Use number of records as a dimension

Hey, Jonathan Drummey, Aaron Clancy, Matt Lutton, etc. ...  Do we need some sort of scaffold data source here to run totals on numbers from zero-through-(three, in this case)?  More than likely, in the real world, three won't be the top number...

The trick here will be filling in zero-values when no data exists, and I'm stuck on that.

• ###### 8. Re: Use number of records as a dimension

Joe, I can get by fine without the zero-values; if you have a solution for one-through-three (in this sample case), that solves my problem.

• ###### 9. Re: Use number of records as a dimension

This is a "how many of X did how much of Y" problem, with a bonus bit of some sparse data. The typical way I approach this using table calcs is:

1) Set up a discrete measure, in this case SUM(Number of Records). This is the "Y" measure.

2) Bring that into the view on Rows or Columns, in this case Rows, and turn *off* Ignore in Table Calculations.

3) Put the dimension that is being counted (the X) onto the Level of Detail Shelf, in this case Player.

4) Set up a table calc that will have a compute using of the X dimension. In this case, all we want to do is count each player, so the calc is IF FIRST()==0 THEN SIZE() END. That will go on the Text shelf.

5) Once that calc is set up, Ctrl+Drag a duplicate of that pill from the Text Shelf to the Filters Shelf and filter for non-Null values. This gets rid of the extra unecessary marks in the view and shifts Tableau back into a non-stacked view that has normal spacing.

If you really want to see a 0 times played and/or 0's for the empty cells, then I'm with Joe, some sort of pre-padding out the data would be a good idea.

Jonathan

• ###### 10. Re: Use number of records as a dimension

I ran into a similar type of scenario yesterday... until the problem became more complicated (I assumed the first iteration of a solution would not work, but posted it for the benefit of others) -- I'd welcome any corrections/clarifications in that post, and I haven't had time to look at the next iteration:

Re: Group customers based on order behaviour