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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.