Forum Discussion
Date Management
Hey all,
I have been trying to figure out a way to solve this date issue I am running into with my data mess. So an example is we have two years worth of calender data. In one day there should not be overlapping time frames.
Example:
| Subject | Start Date | Start Time | End Date | End Time |
| Tentatively available | 7/21/2019 | 9:00 AM | 7/21/2019 | 10:30 AM |
| call sheet | 7/21/2019 | 11:00 AM | 7/21/2019 | 4:00 PM |
| Assesories | 7/21/2019 | 3:00 PM | 7/21/2019 | 5:00 PM |
| Maintanance | 7/21/2019 | 5:00 PM | 7/21/2019 | 5:30 PM |
So this could be an example of one days date data we pull. Now I am going to show a table of what my goal is:
| Subject | Start Date | Start Time | End Date | End Date |
| Tentatively available | 7/21/2019 | 9:00 AM | 7/21/2019 | 10:30 AM |
| call sheet | 7/21/2019 | 11:00 AM | 7/21/2019 | 4:00 PM |
| Assesories | 7/21/2019 | 4:00 PM | 7/21/2019 | 5:00 PM |
| Maintanance | 7/21/2019 | 5:00 PM | 7/21/2019 | 5:30 PM |
So, basically there can not be overlapping time frames for anyday of data. Also, there is a rank for these subjects. Meaning if a call sheet has a time interference with another subject, lets say assesories due to this example, then the call sheet holds the interfered time within its start time and end time.
Ranking of subjects: 1. Call Sheet 2.Assesories 3.Maintanance 4.Tentatively available.
I have previously posted this in the DAX forum and was told this was a power query post. Would appreciate any direction,
Since you posted in two places, I had to take a shot at this one. Turned out to be a little tricky, and solved more easily in DAX IMO. I put your data into a table called "Schedule" and added these two calculated columns to get your desired result. If it works for you and you want explanation of how it works, please let me know.
Priority = SWITCH(Schedule[Subject], "call sheet",1,"Assesories",2,"Maintanance",3,"Tentatively available",4)Adj Start Time =var starttime = Schedule[Start Time]var endtime = Schedule[End Time]var currentpriority = Schedule[Priority]var conflictTF = CALCULATE(COUNTROWS(Schedule), All(Schedule), Schedule[Priority]<currentpriority, Schedule[Start Time]<endtime, Schedule[End Time]>starttime)>0 // returns True or False if a higher priority meeting conflicts with this meetingreturn if(conflictTF, CALCULATE(MAX(Schedule[End Time]), All(Schedule), Schedule[Priority]<currentpriority, Schedule[Start Time]<endtime, Schedule[End Time]>starttime),starttime) // if a conflict, finds the max end time of any conflicting higher priority meetings
4 Replies
- mahoneypatMicrosoft Employee
Since you posted in two places, I had to take a shot at this one. Turned out to be a little tricky, and solved more easily in DAX IMO. I put your data into a table called "Schedule" and added these two calculated columns to get your desired result. If it works for you and you want explanation of how it works, please let me know.
Priority = SWITCH(Schedule[Subject], "call sheet",1,"Assesories",2,"Maintanance",3,"Tentatively available",4)Adj Start Time =var starttime = Schedule[Start Time]var endtime = Schedule[End Time]var currentpriority = Schedule[Priority]var conflictTF = CALCULATE(COUNTROWS(Schedule), All(Schedule), Schedule[Priority]<currentpriority, Schedule[Start Time]<endtime, Schedule[End Time]>starttime)>0 // returns True or False if a higher priority meeting conflicts with this meetingreturn if(conflictTF, CALCULATE(MAX(Schedule[End Time]), All(Schedule), Schedule[Priority]<currentpriority, Schedule[Start Time]<endtime, Schedule[End Time]>starttime),starttime) // if a conflict, finds the max end time of any conflicting higher priority meetings- ConnorHMicrosoft Employee
For some reason it is not returning the right start time. Could this be because this formula searches a whole table rather than by day? I am geting 5:30pm Start time for every value.
- mahoneypatMicrosoft Employee
Please confirm you are using the expression in calculated columns and not a measure (expression would need to be adjusted for measure). Did it work when you apply it to the sample data your provided? Are there differences with your actual data? Did you have to modify the expression?
Regards,
Pat