cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Felipe_Nery
New Member

Adding Values Between Hours

Hello, I have data with the date/time that a sale occurred, and I need to make a table that gathers sales for all days of a certain time interval.
For example:
10/10/2020 09:15 = $50
11/10/2020 09:40 = $150
12/10/2020 09:50 = $50
10/13/2020 10:09 = $350

In the break:
- 9:00 am to 10:00 am sold in total = $250
- 10:00 am to 11:00 am sold in total = $350

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Felipe_Nery , You can create a time table with buckets and use that. First split date and time from datetime in power query or DAX.

 

In DAX

 

Date = [datetime].date
or
Date = date(year([datetime]),month([datetime]),day([datetime]))

DateTime.Date([datetime])

Time = [datetime].Time
or
Time = Time(hour([datetime]),minute([datetime]),second([datetime]))

 

Create a time table join with time and use that

https://kohera.be/power-bi/how-to-create-a-time-table-in-power-bi-in-a-few-simple-steps/

https://radacad.com/script-for-creating-time-table-in-power-bi-with-hours-minutes-and-seconds-bucket...

 

Add hourly bucket  like 

 

time([Hour],0,0) & " - " time([Hour]+1,0,0) 

 

sort this on hour if needed

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Felipe_Nery , You can create a time table with buckets and use that. First split date and time from datetime in power query or DAX.

 

In DAX

 

Date = [datetime].date
or
Date = date(year([datetime]),month([datetime]),day([datetime]))

DateTime.Date([datetime])

Time = [datetime].Time
or
Time = Time(hour([datetime]),minute([datetime]),second([datetime]))

 

Create a time table join with time and use that

https://kohera.be/power-bi/how-to-create-a-time-table-in-power-bi-in-a-few-simple-steps/

https://radacad.com/script-for-creating-time-table-in-power-bi-with-hours-minutes-and-seconds-bucket...

 

Add hourly bucket  like 

 

time([Hour],0,0) & " - " time([Hour]+1,0,0) 

 

sort this on hour if needed

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

Thank you, I spent days trying. I am Brazilian, and here I didn't find any tutorial about it.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!