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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculate between dates and times

Hello,

I'm looking for some help with determining the number of orders between two dates and times and hope I can get some guidance here. I am able to calculate if yesterday and today with: 

OrdersPending = CALCULATE ( 
DISTINCTCOUNT ( order[Delivery] )
, DATESBETWEEN ( order[Order Date]
, TODAY()-1
, TODAY())
, order[location_check] = 0
)

However I'm not clear on how it would work with the date/time portion of between yesterday at 2pm and today at 2pm. 

 

Many thanks for help and clarification.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

I created some data:

1.png

Put Today and Today-1 in the Card, Today shows 12:00:00AM of the current day, Today-1 shows 12:00:00AM of yesterday

So the range of Today and Today-1 is >= 12:00:00AM of yesterday &&<= 12:00:00AM of today

2.png

If you want to calculate yesterday's 2:00 pm to today's 2:00 pm

The following dax can be used:

 

OrdersPending1 =
CALCULATE(
    DISTINCTCOUNT('Table'[order]),
    FILTER(ALL('Table'),'Table'[date]>=TODAY() - 10/24 &&'Table'[date]<=TODAY() + 14/24 &&'Table'[location_check]=0))

 

If you want to calculate yesterday's 12 am to today's 12 pm

The following dax can be used:

 

OrdersPending2 =
CALCULATE(
    DISTINCTCOUNT('Table'[order]),
    FILTER(ALL('Table'),'Table'[date]>=TODAY()-1 &&'Table'[date]<TODAY() +1 &&'Table'[location_check]=0))

 

Result:

3.png

 

Best Regards,

Liu Yang

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @Anonymous ,

I created some data:

1.png

Put Today and Today-1 in the Card, Today shows 12:00:00AM of the current day, Today-1 shows 12:00:00AM of yesterday

So the range of Today and Today-1 is >= 12:00:00AM of yesterday &&<= 12:00:00AM of today

2.png

If you want to calculate yesterday's 2:00 pm to today's 2:00 pm

The following dax can be used:

 

OrdersPending1 =
CALCULATE(
    DISTINCTCOUNT('Table'[order]),
    FILTER(ALL('Table'),'Table'[date]>=TODAY() - 10/24 &&'Table'[date]<=TODAY() + 14/24 &&'Table'[location_check]=0))

 

If you want to calculate yesterday's 12 am to today's 12 pm

The following dax can be used:

 

OrdersPending2 =
CALCULATE(
    DISTINCTCOUNT('Table'[order]),
    FILTER(ALL('Table'),'Table'[date]>=TODAY()-1 &&'Table'[date]<TODAY() +1 &&'Table'[location_check]=0))

 

Result:

3.png

 

Best Regards,

Liu Yang

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

lbendlin
Super User
Super User

First of all you would have to specify which 2PM you mean.  And then you would have to replace the DATESBETWEEN with a custom formula that does number math  (2PM would be 14/24 = 0.58333333) .

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.