Copy this into a new blank query and see if that works for you
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrCwMjZRitWJVjI0tzIwArOMDK1MDSBixlZGhmCWgbGVoalSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Time stamp" = _t]),
ChType = Table.TransformColumnTypes(Source,{{"Time stamp", type time}}),
AddShift = Table.AddColumn(ChType, "Custom", each if List.Contains( List.Times( #time(6,0,0), 12*60*60, #duration(0,0,0,1)), [Time stamp] ) then "Day shift" else "Night shift", type text)
in
AddShift
Awesome, I was just working on this but did it in a much more roundabout way…all the time I was thinking…“how would/will @Melissa do this”…I don’t need to wonder anymore
So…your use of List.Times…you create a starting point of 6am by using (6, 0, 0), create a list/range of values by multiplying the 12 hours & 60 mins & 60 secs…incrementing by 1 second at a time and if the time falls in this range then it is “Day Shift”?
@DavieJoe exactly, this creates a list with a starting value 06:00:00 and an ending value of 17:59:59
BTW you can copy that bit into a new blank query to see the list it generates, if that’s helpful
Hi @Melissa thanx once again. It really worked for the values I posted above, as an example. But my true goal is to apply to a table which has a Time stamp column. Therefore, how can I do it? Changing the source at the M code perhaps? But how?
Don’t follow either… please provide a sample that clarifies why the provided solution doesn’t work for you. Looking at the [Time stamp] column in your screenshot that appears to be of the correct datatype so wouldn’t expect any issue there
Hi once again @Melissa and @DavieJoe . Thank you for your patience . Sorry if my explanation wasn’t clear enough. I’ll explain further.
The small sample of the dataset I’ve provided on first hand was just an example. And indeed, I copied @Melissa 's solution and it worked perfectly, for that small example of dataset.
What I really want is: how can I apply the solution provided (the steps) to a larger dataset? That’s why I provided an example of the dataset I have on the picture above. It’s not just 5 rows.
And by the way (it’s not a secret) this is dataset from the current EDNA challenge 19. Are you following me now?