6 Replies Latest reply on Aug 18, 2012 3:14 PM by Li Chang

# Count number of columns in the work sheet?

Hi, all:

I am wondering how can I count number of columns in the work sheet? I know SIZE() can return number of rows in the partition. Is there a similar function applying to count of columns?

One side note: have you noticed that SIZE() actually gives number of columns in the partition? Like attached...

Li

• ###### 1. Re: Count number of columns in the work sheet?

Li

SIZE() works either way depending on what you 'compute using':

Or

See attached.

--Shawn

1 of 1 people found this helpful
• ###### 2. Re: Count number of columns in the work sheet?

Hi, Shawn:

Thanks for the reply. It works.

Probably I am asking too much. But is there a way to set "Results computed along" using Table Across, Down, etc when creating new fields? As seen from the screenshot below, it does not give that many choices at the first place.

I have to do a calculation = (Number of rows -1) *(number of columns -1) (a.k.a degree of freedom). It would be quite a pain to make changes manually since I have many sheets to calculate.....Thanks again.

Li

• ###### 3. Re: Count number of columns in the work sheet?

Something like the attached? (Really not sure where you're going with this).

--Shawn

• ###### 4. Re: Count number of columns in the work sheet?

Mmm....I wanted to get the right [Li Calc], without extra step to "computing choosing" in [Size Across] and [Size Down]. However the attached won't give the right result because the default setting for [Size Across] and [Size Down] is computing by Table Across.

Li

• ###### 5. Re: Count number of columns in the work sheet?

Li,

You're right, you have to put the Size Across and Size Down on the level of detail shelf and set their compute using first. Then when you put Li Calc on the text shelf you'll get the correct result:

I'm beginning to think what you're really looking for is some combination of PREVIOUS() FIRST() LAST() and/or LOOKUP(). But I'm having difficulty understanding what you're trying to accomplish 'automatically'. As Joe Mako is fond of saying Tableau can do anything, so I'm sure it can be done.

He did a an excellent webEx on Thursday that covered table calculations and show the use of all the functions I mentioned above. It's worth checking out. If nothing else download his workbook and go to these tabs:

Hope this helps,

--Shawn

1 of 1 people found this helpful
• ###### 6. Re: Count number of columns in the work sheet?

Awesome! I am gonna check out Joe's webex. Thanks for your time answering my questions. Just tag on the "Tableau can do anything"comment, I am fully +1  =]. -Li