Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I'm working on a system to report Outlook calendar events, mainly the type of event, the total time spent on each type of event and the total working hours of each team member. I use an add-in to export all the data into an Access file.
My problem is with overlapping events. Here is an example:
What I have in PBI is a query to combine reports from several team-members into a table and sort all events by 'Start'. I also have a calculated column named 'Day' to get only the date from the 'Start' datetime (example in Excel):
So, I would need something like:
WorkTime = IF( Event[End] > nextEvent[Start]); [Duration] - ((Event[End] - nextEvent[Start]) / 2); [Duration])
This is meant to subtract half of the overlapping time to both overlapping events.
And this would have to be filtered by 'Day' and 'EmployeeID'.
I am aware this would have to be completed with further conditions to account for other overlapping situations, but at this point I'm concerned with the method to compare adjacent records.
Can someone get me started on this?
Thank you,
Tiago Jordão
Solved! Go to Solution.
The FILTER expression would look like this (you can only pass one predicate to the function, so you will have to use the && operator)
FILTER(Table1 , [EmployeeName]= EARLIER( [EmployeeName] ) && [Day]=EARLIER([Day]))
From what I understand, you are primarily interested in getting the value in the [Start] column for the next row.
I would write something like this:
CALCULATE( MIN(Table1[Start]) , ALLEXCEPT(Table1, Table1[EmployeeName]) , FILTER( ALL(Table1[Start]), [Start] > EARLIER([Start]) ) )
CALCULATE( MIN(Table1[Start]) , FILTER(Table1
, [EmployeeName]= EARLIER( [EmployeeName] )
&& [Day]=EARLIER([Day])
)
, FILTER( ALL(Table1[Start]), [Start] > EARLIER([Start]) )
)
Note that EARLIER does not mean what most people think it means when starting with DAX.
Hi @descalabro,
To get the End time of previous subject, you need to create a rank column by using RANKX function, and then use LOOKUPVALUE function to get that value.
Rank = RANKX(FILTER(Table1,Table1[Day]=EARLIER(Table1[Day])),Table1[Start],,ASC)
PreviousSubjectEnd = LOOKUPVALUE(Table1[End],Table1[Rank],Table1[Rank]-1,Table1[Day],Table1[Day])
Reference
https://msdn.microsoft.com/en-us/library/gg492185.aspx?f=255&MSPPError=-2147217396
https://msdn.microsoft.com/en-us/library/gg492170.aspx
Regards,
Charlie Liao
Thank you for all your replies.
@v-caliao-msft, Thank you. I've successfully applied your method, but I've looked everywhere for a way to add a second criteria so that the ranking can be done by the daily tasks of each team-member. I don't want to rank the times between team-members, I just need to provide an indication so the DAX will not compare between datetimes of diferent people within the same day. I can't seem to find a filtering option that doesn't require some kind of evaluation; something like:
Rank = RANKX(FILTER(Table1, Table1[EmployeeName]= 'EachEmployee'; Table1[Day]=EARLIER(Table1[Day])),Table1[Start],,ASC)
I know the syntax doesn't make sense, it's just an idea of what I want to do.
Thanks,
Tiago Jordão
The FILTER expression would look like this (you can only pass one predicate to the function, so you will have to use the && operator)
FILTER(Table1 , [EmployeeName]= EARLIER( [EmployeeName] ) && [Day]=EARLIER([Day]))
From what I understand, you are primarily interested in getting the value in the [Start] column for the next row.
I would write something like this:
CALCULATE( MIN(Table1[Start]) , ALLEXCEPT(Table1, Table1[EmployeeName]) , FILTER( ALL(Table1[Start]), [Start] > EARLIER([Start]) ) )
CALCULATE( MIN(Table1[Start]) , FILTER(Table1
, [EmployeeName]= EARLIER( [EmployeeName] )
&& [Day]=EARLIER([Day])
)
, FILTER( ALL(Table1[Start]), [Start] > EARLIER([Start]) )
)
Note that EARLIER does not mean what most people think it means when starting with DAX.
@LaurentCouartou, thank you, this is excellent help!
Before you edited your answer, I changed it a little bit:
NextTaskStart = CALCULATE(MIN('TeamReport'[Start]); ALLEXCEPT('TeamReport'; 'TeamReport'[TeamMember]; 'TeamReport'[Day]); FILTER(ALL('TeamReport'[Start]); [Start] > EARLIER([Start])) )
It seems to be working perfectly (different names here):
Would you recommend doing it as you posted?
TJ
I recommend you use the formula that returns the expected results.
Generally when doing things of this nature, you want to use the EARLIER function.
https://msdn.microsoft.com/en-us/library/ee634551.aspx
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
84 | |
67 | |
59 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |