Forum Discussion
Relationship with First Matching Record
Good morning!
I'm trying to create a relationship between two objects based on some criteria, and I'm having some difficulty coming up with the right definition for their relationship. In my data set I have Cases and Work Orders, where I might have many work orders to any one case. The important part of the data looks like this:
Case:
- ID
Work Order:
- Case ID
- Engineer Assigned
- Created Date
I need to create a one-to-one relationship between the two using only the first work order chronologically (by created date) where engineer assigned isn't blank. I've attempted to solve this myself by creating a custom table using the following:
FirstSiteVisitWO = SUMMARIZE(FILTER('Work Order', 'Work Order'[Engineer_Assigned] <> BLANK()), 'Work Order'[Case_ID],"FirstWO",MIN('Work Order'[Created_Date]))
The problem I've got now is that a good number of cases I'm expecting to see have been filtered out of my data set by this, and the ones I am seeing don't seem to consistently be the right work order associated. Can anyone suggest the correct way to make this related table?
Thanks!
parry2kAfternoon again. I may have rubber duck'd this with the example set. Since that worked, I've rebuilt my larger data set and cut out a lot of chaff. The numbers appear to be working, leading me to think it was a larger problem with the data set as a whole, rather than specific to this relationship.
9 Replies
- JFoxFrequent Visitor
It'll be easier for me to make a mock-up rather than prune sensitive data out of the data set. Give me a moment.