
1. Re: Newbie, having difficulty with COUNTD.
Ankit Bansal Jan 15, 2019 8:39 PM (in response to Nandhini Gopalan)1 of 1 people found this helpfulHi Nandhini,
If you do COUNTD(COLX) , you will get always 1 for each value of COLX. Not sure what you are looking, you can try COUNT(COLX) instead of COUNTD.
Thanks,
AB

2. Re: Newbie, having difficulty with COUNTD.
megha gawali Jan 15, 2019 11:09 PM (in response to Nandhini Gopalan)1 of 1 people found this helpfulHello Nandhini,
Try this one
{ FIXED [Column name]:SUM([Number of Records])}

3. Re: Newbie, having difficulty with COUNTD.
Jonathan Drummey Jan 16, 2019 5:52 AM (in response to Nandhini Gopalan)1 of 1 people found this helpfulHi,
COUNTD() counts unique values, not records. Here's an overview of the three counting aggregations:
COUNTD(X) counts the distinct (unique) values of X in the current context. With X as a dimension in the view (i.e. the values of X are setting the context for the aggregation) then COUNTD(X) is going to return 1 because there is only one unique value of X (the countd) for each X (dimension).
COUNT(X) counts each nonnull value of X once for each record in the current context. Another way of saying this is that it's SUM(IF NOT ISNULL([X]) THEN 1 ELSE 0 END). With X as a dimension in the view then COUNT(X) will return the number of record for each X and then if X is Null return 0.
SUM(Number of Records) counts the number of records in the current context. With X as a dimension in the view then SUM(Number of Records) will return the number of records for each X.
So in this case you're going to want to use COUNT(X) or SUM(Number of Records) to get the desired results.
@Megha  {FIXED [Column name]: SUM([Number of Records])} will also act as a sum, however it has two issues that I believe make is less suitable for this task. First of all it's making Tableau do extra work to resolve the LOD expression when SUM([Number of Records]) will do just fine, secondly due to Tableau's internal order of operations the FIXED LOD expression is computed before regular dimension filters are applied. This requires us to remember to change dimension filters to context filters if we want to affect the results and it's all too easy to forget, especially for new users.
Regards,
Jonathan

4. Re: Newbie, having difficulty with COUNTD.
Nandhini Gopalan Jan 16, 2019 10:37 AM (in response to Ankit Bansal)1 of 1 people found this helpfulThank you Ankit. I did this initially, but I want to get the total number of rows of only column X. COUNTD(COL X), COUNT(COL X), SUM(number of records) or SUM(COL X) all give me the total number of records in the table itself and not the number of rows in Col X that is 10,000.

5. Re: Newbie, having difficulty with COUNTD.
Nandhini Gopalan Jan 16, 2019 11:11 AM (in response to megha gawali)Thank you @Megha! It showed me the same value as the SUM though.

6. Re: Newbie, having difficulty with COUNTD.
Nandhini Gopalan Jan 16, 2019 11:11 AM (in response to Jonathan Drummey)Thank you for the detailed explanation Jonathan Drummey. Sum() worked after I removed an additional data source. I dont remember the reason I added it but that was the one causing problem.