3 Replies Latest reply on Oct 1, 2018 4:12 PM by Ken Flerlage

# Distinct Count of ID's with the same Start and End Days

Hello,

I recently began using tableau and had a quick question I'm trying to write a function that would halp me Count the number of distinct order ID's when the start time (order que date) equals terminate time (order completed date). Here's the formula i'm using but unsuccessfuly:

COUNTD(IF([StarttimeAsDate]=[Today])THEN 1 ELSE 0

AND

If([TerminatetimeAsDate]=[Today] )THEN 1 ELSE 0)

END

Could anyone tell where I'm going wrong with this formula?

Thanks,

Mike

• ###### 1. Re: Distinct Count of ID's with the same Start and End Days

COUNTD(IF [StarttimeAsDate]=[Today] AND [TerminatetimeAsDate]=[Today] THEN [Order ID] END)

Note: The reason we use [Order ID] in this is that COUNTD counts distinct values. If you return 1 or 0, then COUNTD will probably always return 1 or 2 as each value (1 and 0) will only be counted once. If we use [Order ID], it will count each distinct order once.

• ###### 2. Re: Distinct Count of ID's with the same Start and End Days

Thank you, Ken, it worked. Appreciate the detailed explanation!

• ###### 3. Re: Distinct Count of ID's with the same Start and End Days

Any time!