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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Custom column based on time value

Hi,

I've not worked with creating a custom formulae where time comparisions are used and was hoping for some pointers.

 

I have two columns:

  1. AppointmentBookedTime: the time a user booked an appointment using our system. eg, 04/07/16 09:22:33
  2. AppointmentTime: the time when the actual appointment is to take place (in the future) e.g. 05/08/ 11:30:00

 

I want to create a cusotm column called BookedTimeBusinessHours that returns a Y/N response for each row where:

  • Y = if an appointment was booked between 9am and 5pm
  • N = if an appointment was booked between 5pm and 9am

 

Any tips on the formulae requried to acheive this?

 

 

 

 

 

2 ACCEPTED SOLUTIONS
radpir
Resolver II
Resolver II

hi there,

 

use this formula for the BookedTimeBusinessHours column:

= if Time.Hour([AppointmentBookedTime]) >= 9 and Time.Hour([AppointmentBookedTime]) <= 17 

   then "Y"

   else "N"

 

hope this works for you,

radpir

View solution in original post

Anonymous
Not applicable

Hi @Anonymous,


radpir's solution seems well, I convert this to dax, you can refer to it:


BookedTimeBusinessHours =
var currentTime=TIME(HOUR([AppointmentBookedTime]),MINUTE([AppointmentBookedTime]),SECOND([AppointmentBookedTime]))
return
IF(AND(currentTime>=TIME(9,0,0),currentTime<=TIME(17,0,0)),"Y","N")

Regards,

Xiaoxin Sheng

View solution in original post

5 REPLIES 5
MAAbdullah47
Helper V
Helper V

Anonymous
Not applicable

Hi @Anonymous,


radpir's solution seems well, I convert this to dax, you can refer to it:


BookedTimeBusinessHours =
var currentTime=TIME(HOUR([AppointmentBookedTime]),MINUTE([AppointmentBookedTime]),SECOND([AppointmentBookedTime]))
return
IF(AND(currentTime>=TIME(9,0,0),currentTime<=TIME(17,0,0)),"Y","N")

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Thank, Xiaoxin! Worked perfectly.

radpir
Resolver II
Resolver II

hi there,

 

use this formula for the BookedTimeBusinessHours column:

= if Time.Hour([AppointmentBookedTime]) >= 9 and Time.Hour([AppointmentBookedTime]) <= 17 

   then "Y"

   else "N"

 

hope this works for you,

radpir

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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