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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
njxfoster
Helper I
Helper I

How to custom date/time column to fit working schedule so I can do calculation correctly

Hi Guys

 

How can I design a column which transform every time that's after 7pm to Next days 10am?

 

I need to create a column about lead reaction time. Which is (Attempt Time - Lead Created Time). However, some Lead Created Time is created after work time, So it can't be use for this calculation. (For example, If a lead is created at 01/01/2021 10:00pm, if a agent response to it at 01/02/2021 10:20am, the response duration will be 12 hours 20 mins. Which is not right. 

 

In order to get the right result I have to set every time thats passed 7pm to 10 am the day after

 

 

Your help will be very appraciated!

 

 

Thanks in advance

 

1 ACCEPTED SOLUTION

Hi @njxfoster 

 

Try this code to add a new column to your table:

New Column = 
Var _PD = time(19,00,00)
Var _SND = time (10,0,0)
Var _Date = DATEVALUE('Table'[Created Date/Time])
Var _Time = TIMEVALUE('Table'[Created Date/Time])
return
if(_Time>_PD,(_Date+1)+_SND,'Table'[Created Date/Time])

 

output:

VahidDM_0-1642648501518.png

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

3 REPLIES 3
VahidDM
Super User
Super User

Hi @njxfoster 

 

Can you post sample data as text and expected output?
Not enough information to go on;

please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
4. Relation between your tables

Appreciate your Kudos!!
LinkedIn:www.linkedin.com/in/vahid-dm/

njxfoster_0-1642647159784.png

Basiclly I want to transform every record thats passed 7:00:00PM into 10AM the next day

 

For example first row is 10/13/2021 8:56:00PM,  the record passed 7:00:00PM so after transformation it should be 10/14/2021 10:00:00AM

 

The fifth record is 2:42:00PM. Its before 7 PM, so it should stay the same

 

 

Thank you for your reply!!

Hi @njxfoster 

 

Try this code to add a new column to your table:

New Column = 
Var _PD = time(19,00,00)
Var _SND = time (10,0,0)
Var _Date = DATEVALUE('Table'[Created Date/Time])
Var _Time = TIMEVALUE('Table'[Created Date/Time])
return
if(_Time>_PD,(_Date+1)+_SND,'Table'[Created Date/Time])

 

output:

VahidDM_0-1642648501518.png

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.