cancel
Showing results for
Did you mean:
Regular Visitor

## Dax DisctinctCount with date condition

So here is my problem, i need to calculate the quantity of different "DOC Number" but only if the Register date is < than Sales Date, in this case the "DOC NUMBER" repeats because it might be 2 different articles

i tried this measure but its not working

MEASURE = CALCULATE(DISTINCTCOUNT('DOC Number'),FILTER( [Table1]), [Sales Date]>=[RegisterDate]))
1 ACCEPTED SOLUTION

Accepted Solutions
Regular Visitor

## Re: Dax DisctinctCount with date condition

i've tryed both the solutions you guys gave, sadly idk why it didnt work so what i did to make it work is to create a columm in the Sales Tables called "Register Date" with this fucntion

RegisterDate= Related('MembershipTable'[Registerdate]

with this and the a mix of the measure i used at the beginning and parts of yours it worked

Tickets = CALCULATE(DISTINCTCOUNT('SalesTable'[DOC Number]),FILTER('SalesTable','MembershipTable'[RegisterDate]<='SalesTable'[SalesDate]))

Thanks a lot for your solutions 3 minds think better than 1 🙂
5 REPLIES 5
Super User IV

## Re: Dax DisctinctCount with date condition

Hello @LuisG2407

Is it because you used >= instead of just > in your measure?  When I test it the logic works if I use < and swap the order.

Regular Visitor

## Re: Dax DisctinctCount with date condition

Hi, thanks for the answer! but my problem persist i forgot to mention that "Register Date" is in another table i have like a sales table and a membership table

Super User IV

## Re: Dax DisctinctCount with date condition

Can you share a sample .pbix with the tables and relationships?  It helps a lot to know how the data is set up.

Community Support Team

## Re: Dax DisctinctCount with date condition

Hi @LuisG2407 ,

Based on having created relationship between this sales table and a membership table which contains the "Register Date", keep Cross filter direction as Both. You may try to create measures like DAX below.

`MEASURE = CALCULATE(DISTINCTCOUNT(Table1[DOC Number]),FILTER(ALLSELECTED( Table1), Table1[Sales Date]>=MAX('membership table'[RegisterDate])))`

Best Regards,

Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Regular Visitor

## Re: Dax DisctinctCount with date condition

i've tryed both the solutions you guys gave, sadly idk why it didnt work so what i did to make it work is to create a columm in the Sales Tables called "Register Date" with this fucntion

RegisterDate= Related('MembershipTable'[Registerdate]

with this and the a mix of the measure i used at the beginning and parts of yours it worked

Tickets = CALCULATE(DISTINCTCOUNT('SalesTable'[DOC Number]),FILTER('SalesTable','MembershipTable'[RegisterDate]<='SalesTable'[SalesDate]))

Thanks a lot for your solutions 3 minds think better than 1 🙂

Announcements

#### Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

#### Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

#### Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

#### Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!