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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
zhris
New Member

Count based on dates in two tables

Hi!

 I have two tables:

  • One has an order ID and a submission date
  • The other has a Completion date.

 

I'm trying to write a DAX measure to count orders where the submission date is on or before the completion date, but I'm running into an error in my syntax. Here's what I'm trying so far:

orders pre = 
CALCULATE(
    DISTINCTCOUNT(Table1[JOB_ID])
       , Table2[Completion Date] >= Table1[JOB_CREATE_DATE]

Is this possible? Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @zhris 

 

You can try the following methods.

Sample data:

vzhangtinmsft_0-1722220735977.png

orders pre = 
CALCULATE(
DISTINCTCOUNT(Completion[Order ID]),FILTER(Completion,[Completion Date]>=MAX(Submission[Submission date])))

vzhangtinmsft_1-1722220761808.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @zhris 

 

You can try the following methods.

Sample data:

vzhangtinmsft_0-1722220735977.png

orders pre = 
CALCULATE(
DISTINCTCOUNT(Completion[Order ID]),FILTER(Completion,[Completion Date]>=MAX(Submission[Submission date])))

vzhangtinmsft_1-1722220761808.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

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

Gaga_Jin
Frequent Visitor

CALCULATE(
COUNTROWS('Orders'),
FILTER(
'Orders',
'Orders'[SubmissionDate] <=
RELATED('Completions'[CompletionDate])
)
)

MattAllington
Community Champion
Community Champion

You need to share details on the tables, the relationships between them and which columns are part of the relationship .



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.