Forum Discussion
If Statement Comparing Dates Between Tables
- 4 years ago
Hi Dawson16 ,
According to your description, here's my solution.
The two tables are related with the ID# column. Then create two calculated columns in the Work Orders table.
Start Date in Project Range? = IF ( 'Work Orders'[Start Date] >= RELATED ( 'Projects'[Start Date] ) && 'Work Orders'[Start Date] <= RELATED ( Projects[Finish Date] ), "In Range", "Out of Range" )Finish Date in Project Range? = IF ( 'Work Orders'[Finish Date] >= RELATED ( 'Projects'[Start Date] ) && 'Work Orders'[Finish Date] <= RELATED ( Projects[Finish Date] ), "In Range", "Out of Range" )Create two calculated columns in the Projects table.
ALL WO Start Dates in Range? = IF ( COUNTROWS ( FILTER ( 'Work Orders', 'Work Orders'[ID #] = EARLIER ( 'Projects'[ID #] ) && 'Work Orders'[Start Date in Project Range?] = "Out of Range" ) ) > 0, "No", "Yes" )ALL WO Finish Dates in Range? = IF ( COUNTROWS ( FILTER ( 'Work Orders', 'Work Orders'[ID #] = EARLIER ( 'Projects'[ID #] ) && 'Work Orders'[Finish Date in Project Range?] = "Out of Range" ) ) > 0, "No", "Yes" )Get the correct result.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Please provide sanitized sample data that fully covers your issue. I cannot help you without meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive. I cannot use screenshots of your source data.
Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523