cancel
Showing results for
Did you mean:

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Employee

## 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,

1 ACCEPTED SOLUTION
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)

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

Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

4 REPLIES 4
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)

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

Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

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.

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

Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

Employee

Hi Pat,

Just went through and yes it does work on the sample data but not my actual data. I should have put out a more rounded example. Thank you so much for your time. I have linked to an Excel file which holds an almost itentical match to my actual data. I think an issue was I have hundereds of different days but from what I understood from the solution is it searches the whole table and adjusts start dates instead of adjusting day by day. Not really sure how to do it.   Dropbox Excel File

Thank you for the help!

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors