# Count Distinct Record after a given date

Hello,

I am trying to calculate how many total patient records I have after a given date.

I already have a measure written that calculates the distinct sample count of my sample ID’s

Total Compliance Patient Samples = DISTINCTCOUNT(Compliance[sample_id])

The new measure I am writing tells me I have too few arguments. Any help would be greatly appreciated. The measure I am attempting to write is below:

CALCULATE([Total Compliance Patient Samples], FILTER(DATESBETWEEN(‘Date’,12/30/2020,12/31/2021)))

Hello @matthew.wright,

Thank You for posting your query onto the Forum.

Well it’s always a bit difficult for the forum members to judge and provide the results without looking at the working of the PBIX file.

But by looking at the formula that you’ve provided in that you haven’t referenced/specified neither any table nor any filter condition. If you don’t have any table and condition than there’s no point of using the “FILTER()” function. Try again by removing that function.

If this doesn’t solve the problem than please upload the mock-up of the data so that members of our forum can assist you in a better and efficient manner.

Thanks and Warm Regards,
Harsh

1 Like

Harsh,

Thanks for your response. I tried your suggestion and it didn’t work. I have attached a demo file.

My data for example purposed has two separate data sets. A date table and patient sample data.

I have a measure that counts all distinct sample numbers. I want to count all sample numbers after a given date. For example, count all sample numbers after 12/30/2020.

Given my example is should count 20 samples.

Any help would be great.

Example File.pbix (124.5 KB)

First I marked your Date table as a Date table.
Second created a relationship between your Date and Fact table and created this measure

``````Total Samples After.. =
CALCULATE( [Total Samples],
Dates[Date] > DATE( 2020, 12, 30 )
)
``````

Here’s your sample file. Example File.pbix (102.7 KB)
I hope this is helpful

Hi @Melissa,

That did the trick! Thanks so much.