March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I have two reports, a leave and official travel report. What I am trying to do is find any overlapping dates between the two reports? The reports cannot be merged together since they are from separate systems. I created and ID key that relates them both to a personnel roster.
1. I need to find the dates that over lap
2. Once I find the dates, I need to figure out how long the person was actually gone.
What I need to check is
The start or end of a leave period is in the middle of an offical travel period:
1. ([leave.start]>=[offical.start] && [leave.start]<=[offical.end]) || ([leave.end]>=[offical.start] && [leave.end]<=[offical.end])
2. If true, find out how many days that they overlap and subtract that differnce from the overall total.
Hi,
Share some data to work with and show the expected result. Share data in a format that can be pasted in an MS Excel file.
Like the above. Trying to determine where dates over lap between the offical and Personnel Travel (Since you can take both in conjunction) like the below which thru into Power Apps
Then detemine the total days gone
Hi @Ferminmj ,
Let's assume you have two tables:
LeaveReport: with columns PersonID, LeaveStart, LeaveEnd
OfficialTravelReport: with columns PersonID, OfficialStart, OfficialEnd
1- Create a measure that checks if there is an overlap between the leave and official travel periods:
OverlapDays =
VAR LeaveStart = SELECTEDVALUE(LeaveReport[LeaveStart])
VAR LeaveEnd = SELECTEDVALUE(LeaveReport[LeaveEnd])
VAR OfficialStart = SELECTEDVALUE(OfficialTravelReport[OfficialStart])
VAR OfficialEnd = SELECTEDVALUE(OfficialTravelReport[OfficialEnd])
-- Check if the leave period overlaps with the official travel period
VAR OverlapStart = MAX(LeaveStart, OfficialStart) -- The later start date
VAR OverlapEnd = MIN(LeaveEnd, OfficialEnd) -- The earlier end date
-- Calculate the number of overlap days, ensuring it is positive
VAR OverlapDuration =
IF(OverlapStart <= OverlapEnd,
DATEDIFF(OverlapStart, OverlapEnd, DAY),
0
)
RETURN
OverlapDuration
2- Create another measure that calculates the total number of days a person was "actually gone," subtracting the overlap from the total leave period:
ActualLeaveDays =
VAR TotalLeaveDuration = DATEDIFF(LeaveReport[LeaveStart], LeaveReport[LeaveEnd], DAY)
VAR OverlapDuration = [OverlapDays] -- Using the previous measure for overlap
RETURN
TotalLeaveDuration - OverlapDuration
Used your measure and got zero on the results, used the selected column to get the date to work
Thanks, I am getting an error whern trying to addthe Date difference to the measure. I can't event create it as its own measure. I did create a column that does the same thing can I use that? Also how do you recommend getting the data back? What table would you put it in to see?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
134 | |
90 | |
90 | |
66 | |
58 |
User | Count |
---|---|
201 | |
137 | |
107 | |
70 | |
68 |