Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi, my problem was this :
Date | Id | User | Job |
10/01/2024 15:01:24 | 001 | Adam | Nurse |
10/01/2024 15:11:24 | 001 | Max | Nurse |
10/01/2024 16:01:24 | 001 | George | Doctor |
15/01/2024 08:00:00 | 002 | Michel | Nurse |
17/02/2024 17:00:50 | 003 | Max | Nurse |
1702/2024 14:10:00 | 003 | George | Doctor |
17/02/2024 15:26:00 | 003 | Patrick | Doctor |
25/03/2024 14:00:00 | 004 | George | Docor |
26/03/2024 12:25:00 | 005 | Anne | Nurse |
26/03/2024 14:15:00 | 005 | Sophie |
For each ID I would like to keep at most 2 ligne :
And I got this solution from @SamWiseOwl
My problem becomes even more complex.
Now I'd like to add this condition: For each group [CurId x CurJob] if Max(Date) - Min(Date) > 1 hour then also keep the minx(Filter(People, 'Nurse table'[Job] <> "Doctor"), [Date])= minTime && curJob <> "Doctor" && diffTime >=1, "Y"
minx(Filter(People, 'Nurse table'[Job] = "Doctor"), [Date])= minTime && curJob = "Doctor" && diffTime >=1
Solved! Go to Solution.
Hi @GOT2021 ,
Based on your description, you can try the following code to see if it's what you're expecting
Filter measure =
VAR curId = SELECTEDVALUE('Nurse table'[Id])
VAR curJob = SELECTEDVALUE('Nurse table'[Job])
VAR curTime = SELECTEDVALUE('Nurse table'[Date])
VAR People = CALCULATETABLE('Nurse table', ALLSELECTED('Nurse table'), 'Nurse table'[Id] = curId)
VAR maxDate = MAXX(People, [Date])
VAR minDate = MINX(People, [Date])
VAR diffTime = DATEDIFF(minDate, maxDate, MINUTE)
RETURN
SWITCH(
TRUE(),
COUNTROWS(People) = 1, "Y",
MAXX(FILTER(People, 'Nurse table'[Job] <> "Doctor"), [Date]) = curTime && curJob <> "Doctor", "Y",
MAXX(FILTER(People, 'Nurse table'[Job] = "Doctor"), [Date]) = curTime && curJob = "Doctor", "Y",
diffTime > 60 && MINX(FILTER(People, 'Nurse table'[Job] <> "Doctor"), [Date]) = curTime && curJob <> "Doctor", "Y",
diffTime > 60 && MINX(FILTER(People, 'Nurse table'[Job] = "Doctor"), [Date]) = curTime && curJob = "Doctor", "Y",
"N"
)
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @GOT2021 ,
Based on your description, you can try the following code to see if it's what you're expecting
Filter measure =
VAR curId = SELECTEDVALUE('Nurse table'[Id])
VAR curJob = SELECTEDVALUE('Nurse table'[Job])
VAR curTime = SELECTEDVALUE('Nurse table'[Date])
VAR People = CALCULATETABLE('Nurse table', ALLSELECTED('Nurse table'), 'Nurse table'[Id] = curId)
VAR maxDate = MAXX(People, [Date])
VAR minDate = MINX(People, [Date])
VAR diffTime = DATEDIFF(minDate, maxDate, MINUTE)
RETURN
SWITCH(
TRUE(),
COUNTROWS(People) = 1, "Y",
MAXX(FILTER(People, 'Nurse table'[Job] <> "Doctor"), [Date]) = curTime && curJob <> "Doctor", "Y",
MAXX(FILTER(People, 'Nurse table'[Job] = "Doctor"), [Date]) = curTime && curJob = "Doctor", "Y",
diffTime > 60 && MINX(FILTER(People, 'Nurse table'[Job] <> "Doctor"), [Date]) = curTime && curJob <> "Doctor", "Y",
diffTime > 60 && MINX(FILTER(People, 'Nurse table'[Job] = "Doctor"), [Date]) = curTime && curJob = "Doctor", "Y",
"N"
)
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
97 | |
69 | |
46 | |
39 | |
33 |
User | Count |
---|---|
158 | |
102 | |
60 | |
43 | |
40 |