Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
FBarri
New Member

Return text value based on cell time value

Hi All, 

I have data of agents logging to work  ,the log in time is captured in hour, minute, seconds , I need to add a column that indicates what shift the agent was working at based on log in time 

NameLog in TimeShift 
James R.2:34:17 PM?
John V.11:53:33 AM?
Shift  NameShift Start TimeShift End Time
Night07:00:00 PM07:00:00 AM
Morning07:00:00 AM07:00:00 PM

 

will it be an if & and formula ? I tried few times but the results were overlapping 

Thank you for you help  🙂

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @FBarri 

 

First change the [Log in Time] column to time type. Then add a custom column with below code. 

if [Log in Time] >= #time(7,0,0) and [Log in Time] < #time(19,0,0) then "Morning" else "Night"

vjingzhang_1-1674008359506.png

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @FBarri 

 

First change the [Log in Time] column to time type. Then add a custom column with below code. 

if [Log in Time] >= #time(7,0,0) and [Log in Time] < #time(19,0,0) then "Morning" else "Night"

vjingzhang_1-1674008359506.png

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Waldo35
Helper I
Helper I

I don't work with AM / PM over here so it automatically converted to 11:53 and 14:34.  Here are a couple suggestions:

 

1. Change to text value, does it keep the PM and AM, if so change to text value then:

if Text.Contains([Column2], "AM") then "Morning" else "Night")

 

or still try the:

if [Column2] >= Time.From("12:00") and [Column2] <= Time.From("23:59") then "Night" else "Morning"

 

Powerbi might understand the time even tho it says AM and PM. But i have no way to test this without changing my PowerBI language settings

 

 

Helpful resources

Announcements
Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.