3 Replies Latest reply on Feb 8, 2016 4:39 PM by Tina Hauser

# Count Number of time an ID appears over the last 12 months

Hello,

I am new to Tableau and I have a requirement to Count the number of times an ID appears in the last 12 months.

And depending on the number of the count, show some text. The text would act as a dimension.

The calculation would look like:

- Get IDs within last 12 months

- Group it by counting how many times it appears

- show some text with regards to the count

Thank you,

Daryl

• ###### 1. Re: Count Number of time an ID appears over the last 12 months

Hi Daryl,

I believe Tableau has this feature built in, and it should be a matter of clicks to get what you are looking for.

I recommend checking out the following KB:

Let me know if this is helpful.

-Kamran

• ###### 2. Re: Count Number of time an ID appears over the last 12 months

COUNTD  only counts how many distinct items are in a set. I need to know how many times a distinct ID appears within the set. In the link provided i would need to know that apple appears twice in east and use that number in a case or if statement

• ###### 3. Re: Count Number of time an ID appears over the last 12 months

Hi Daryl!

I used the Superstore data to simulate what you've described. Please see the attached workbook.

Filter on Order Date, choose Relative dates, and enter last 12 months. (I used 24 just to make sure we grabbed some data since the Superstore data is older.)

Create a calculated field for however you want to group your ID counts. Something like this (named 'Text' in the attached workbook):

IF sum([Number of Records]) < 10 then 'Small'

ELSEIF SUM([Number of Records]) <= 20 then 'Medium'

ELSE 'Large'

END

Then use the Number of Records measure to count the number of instances of each Order ID.

Is this what you were looking for? Hope it helps!

Tina