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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Dirk_97
Regular Visitor

Calculate sales between two time values

Hi,

 

I'm trying to calculate the total sales per weekday, while some of the sales happen after 00:00:00. So, what I want is to manipulate the weekdays. Example: On tuesday 03:12:49 there is a sale, but I want to put that sale at the monday before.

 

The 'new days' I want to create begin at 10:00:00 AM and end at 09:59:59 AM the next weekday.

Then e.g. create 7 DAX formulas:

'Sales monday' =  
'Sales tuesday' =
etc.

 

Can you please help me?

1 ACCEPTED SOLUTION
Mikelytics
Resident Rockstar
Resident Rockstar

Hi @Dirk_97 ,

 

I think I have an idea. I would recommend you to manipulate the data in Power Query like the following.

 

Lets assume I have a list of DateTime values.

Mikelytics_1-1667427188721.png

transform the data into decimal

Mikelytics_2-1667427260805.png

data are translated into decimals:

Mikelytics_5-1667427487057.png

 

 

Now you create a custom column. You want to shift by 10 Hours and a full 1 is like 1 day in date format. So I want to reduce the decimal value by 10/24 pieces.

Mikelytics_4-1667427453822.png

Now it looks like this

Mikelytics_9-1667427814896.png

 

 

After adding the custom column I transform the data back to date time

Mikelytics_7-1667427606685.png

 

result: in the new column all DateTime values are reduced by 10 hours. Now use the new column for all your calculations.

Mikelytics_8-1667427722274.png

 

Best regards

Michael

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your kudos.

 

@ me in replies or I'll lose your thread.

 

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

View solution in original post

1 REPLY 1
Mikelytics
Resident Rockstar
Resident Rockstar

Hi @Dirk_97 ,

 

I think I have an idea. I would recommend you to manipulate the data in Power Query like the following.

 

Lets assume I have a list of DateTime values.

Mikelytics_1-1667427188721.png

transform the data into decimal

Mikelytics_2-1667427260805.png

data are translated into decimals:

Mikelytics_5-1667427487057.png

 

 

Now you create a custom column. You want to shift by 10 Hours and a full 1 is like 1 day in date format. So I want to reduce the decimal value by 10/24 pieces.

Mikelytics_4-1667427453822.png

Now it looks like this

Mikelytics_9-1667427814896.png

 

 

After adding the custom column I transform the data back to date time

Mikelytics_7-1667427606685.png

 

result: in the new column all DateTime values are reduced by 10 hours. Now use the new column for all your calculations.

Mikelytics_8-1667427722274.png

 

Best regards

Michael

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your kudos.

 

@ me in replies or I'll lose your thread.

 

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors