Forum Discussion

ConnorH's avatar
ConnorH
Microsoft Employee
6 years ago
Solved

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 n...
  • mahoneypat's avatar
    6 years ago

    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 meeting
    return 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