Forum Discussion
Flagging DateTime records in Power Query with multiple conditions
- 6 years ago
Hi Mann ,
Try this, 14 now receives a 1, as do 12, 16, and 17 (I added a test for 21 which works as well)
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathanielif DateTime.From(Number.RoundUp(Number.From([Status From Time])*288,0)/288) <> DateTime.From(Number.RoundUp(Number.From([Status To Time])*288,0)/288) then "1" else if Number.Mod(Time.Minute([Status From Time]),5) = 0 and Time.Second([Status From Time])= 0 and [Status From Time]= [Status To Time] then "1" else if Number.Mod(Time.Minute([Status From Time]),5) = 0 and Time.Second([Status From Time])= 0 or Number.Mod(Time.Minute([Status To Time]),5) = 0 and Time.Second([Status To Time])= 0 then 1 else if Duration.Minutes([Status To Time]-[Status From Time])<=5 then 0 else "-"
Hi Nathaniel_C
Thanks for the reply on this.
Flag of 14,16 and 17 has to be "1" only as per this rule:
"Flag "1" if records have start time and end time across standard values like (Ind ID= 14,16,17)"
Let me elaborate:
We need to show some chart at every 5 min interval (standard values like 8:00:00, 8:05:00, 8:10:00...) so when for any individual he is detected on these standard values he should be picked for calculation.
Therefore,
14 - when his end time detected on standard value
16- when he is detected at standard value between start time and end time
17- when his start time detected on standard value.
I hope this clarifies.
I checked your code, it worked fine can we include record 14 also there?
Mann
Hi Mann ,
Try this, 14 now receives a 1, as do 12, 16, and 17 (I added a test for 21 which works as well)
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel
if DateTime.From(Number.RoundUp(Number.From([Status From Time])*288,0)/288) <> DateTime.From(Number.RoundUp(Number.From([Status To Time])*288,0)/288) then "1"
else if Number.Mod(Time.Minute([Status From Time]),5)
= 0 and Time.Second([Status From Time])= 0 and [Status From Time]= [Status To Time] then "1"
else if Number.Mod(Time.Minute([Status From Time]),5)
= 0 and Time.Second([Status From Time])= 0 or Number.Mod(Time.Minute([Status To Time]),5)
= 0 and Time.Second([Status To Time])= 0 then 1
else if Duration.Minutes([Status To Time]-[Status From Time])<=5 then 0
else "-"
- Mann6 years agoResolver III
- Nathaniel_C6 years agoCommunity Champion
Hi Mann ,
You are welcome!Nathaniel