Hello everyone,
I run a query with the addition of a column according to certain criteria (I want to receive the shift according to the opening time of the service call)
Everything works fine except for 2 lines that show night shift instead of morning.
i add 2 picture
I suspect that this is due to the fact that you are dealing with texts, not real time values. Could it be that the time 08:40:00 contains a leading space? The text " 08;40:00" will be evaluated as greater than the text "23:00", thus returning "Night"
In Power Query, make sure that you set the data type for the call time column to Date/Time. Then extract the time only into the time_for_shift_sebregation column.
And the code for the added column should use the #time() function. It could look like this:
if [time_for_shift_segregation] >= #time(23,0,0) then "Night" else
if [time_for_shift_segregation] >= #time(15,0,0) then "Evening" else "Morning"
If this makes no sense, please upload a file containing the underlying data and query for what is show shown in your screenshot.
Hi Riny ,
thanks for your answer but i still didn't
Understand how to do that ,
the column already modify as time
And i try to write the formula with the time i didn't succeed
please tell me what you need to see and i will show you
Not sure what's going on here. When I try to compare a value in a Time column to a text like "06:00" I get an error. So, I don't understand howe you get PQ to return something else to begin with.
Can you upload the file? Not just a screenshot.
Yes i attached the file
but i hope you can see the query as well
Thanks for the file. Any particular reason why it's in the old xls format?
I couldn't really follow through your query as it connected to files in a folder on your computer. But I took your script and connected it to the table in Sheet1, assuming that this is the data you worked off. You'll find it in the "Table1" query that loads the green table in Sheet3.
At the point where you added the column that "calculates" the Shift, the [time_for_shift_segmentation] column is NOT set to Date. It's still a Text. Corrected that and changed the next step to the formula I mentioned earlier (though I misread segmentation for segregation in my response).
Then the query and/or data generated errors in the last column. I just replaced them wit 00:00:00.
Since the data table did not have the problem records that you showed in your screenshots in it, I added a TEST row with an 08:40:00 time stamp which correctly becomes "Morning".
See attached file (saved as an xlsx, by the way).
Riny thank you its work !
you are the master 🙂
Moshe