Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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

Captura.JPG

i tried this measure but its not working

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

Hi @v-xicai @jdbuchanan71 

 

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 🙂 

View solution in original post

5 REPLIES 5
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

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])))

If I misunderstood it, could you please share your sample data or desired output screenshots for further analysis, you can also upload sample pbix to OneDrive and post the link here. Do mask sensitive data before uploading.

 

Best Regards,

Amy

 

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

 

Anonymous
Not applicable

Hi @v-xicai @jdbuchanan71 

 

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 🙂 
jdbuchanan71
Super User
Super User

Hello @Anonymous 

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.

distinctcount.jpg

Anonymous
Not applicable

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

@Anonymous 

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.