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
ranz_vincent
Frequent Visitor

Need help with formulating time and date

Hello everyone I am trying to find a way to find how many deliveries are within a certain time window. Like i need a way to identify what truck arrived before 6am of the following day, after 6am but before 12nn, after 12nn but before 6pm and 6pm onwards. The starting date is the order_date.image.png

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @ranz_vincent ,

 

Add a new custom column like this:

arrivalDayWindow =
if [date_arrived_to_store] = [order_date] then "Same Day"
else if [date_arrived_to_store] = Date.AddDays([order_date], 1) then "Next Day"
else "Other"

 

Then another one like this:

arrivalTimeWindow =
if [time_arrived_to_store] < #time(6, 0 ,0) then "Before 0600"
else if [time_arrived_to_store] >= #time(6, 0 ,0)
    and [time_arrived_to_store] < #time(12, 0 ,0) then "0600-1200"
else if [time_arrived_to_store] >= #time(12, 0 ,0)
    and [time_arrived_to_store] < #time(18, 0 ,0) then "1200-1800"
else "After 1800"

 

Between these two columns you should be able to make counts of any scenario you need.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
BA_Pete
Super User
Super User

Hi @ranz_vincent ,

 

Add a new custom column like this:

arrivalDayWindow =
if [date_arrived_to_store] = [order_date] then "Same Day"
else if [date_arrived_to_store] = Date.AddDays([order_date], 1) then "Next Day"
else "Other"

 

Then another one like this:

arrivalTimeWindow =
if [time_arrived_to_store] < #time(6, 0 ,0) then "Before 0600"
else if [time_arrived_to_store] >= #time(6, 0 ,0)
    and [time_arrived_to_store] < #time(12, 0 ,0) then "0600-1200"
else if [time_arrived_to_store] >= #time(12, 0 ,0)
    and [time_arrived_to_store] < #time(18, 0 ,0) then "1200-1800"
else "After 1800"

 

Between these two columns you should be able to make counts of any scenario you need.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Just finished trying this and it worked perfectly. Thanks for the help

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!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

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.