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
Anonymous
Not applicable

Diference between 2 dates by period

Hi,

I need to calculate Time utilization like this:

TU = DIVIDE([Rented Out] , [Days])
I need the amount of rented out in days of each vehicle, but what I can not figure out is how to outcome by a selected period (diference of days betwen end date and start day):
RodrigoN_0-1658146581397.png

 

 

Rented out is the amount of days with machines rented and Days, the amount of aviable days without weekends in the same period.
The problem is that my database has diferent machines whose are rented by day. I have a list of those machines with the start date (Fecha inicio) and end date (Fecha Fin). The report should be able to visualize TU by the user time selected.
I can not find out the way to calculate the workday (without weekend) and to calculate properly by month, for example if a machine starts june 29th  and ends july 5th should count 2 days in june, and 3 in july (without week end).
I don not know why NETWORKDAYS is not working.
 
This is my DAX formula and my database and calendar table.
Rented Out =
VAR Vehic =
CALCULATE(
COUNT(_Mateco_Union_MovimientoVehiculos[Vehiculo])
)
VAR Dates=
CALCULATE(
SUM(_Mateco_Union_MovimientoVehiculos[Fecha de fin corregida]) - SUM(_Mateco_Union_MovimientoVehiculos[Fecha Inicio]),
FILTER(Calendario , Calendario[Workday] = 1)
)
RETURN
CONVERT((Vehic + Dates), INTEGER)
 
RodrigoN_1-1658146581793.png

 

RodrigoN_2-1658146581591.png

 

VehicleStarting dateEnding date
XS3G7531/01/2022 0:0001/02/2022 0:00
XS3G7501/02/2022 0:0002/02/2022 0:00
NBT3 -511/01/2022 0:0012/01/2022 0:00
N89M 37211/02/2022 0:0015/02/2022 0:00
XS3G7502/02/2022 0:0003/02/2022 0:00
NBT3 -502/02/2022 0:0002/02/2022 0:00
NBT3 -512/01/2022 0:0013/01/2022 0:00
XS3G7511/01/2022 0:0012/01/2022 0:00
NBT3 -502/02/2022 0:0004/02/2022 0:00
XS3G7512/01/2022 0:0013/01/2022 0:00
XS3G7513/01/2022 0:0013/01/2022 0:00
XS3G7503/02/2022 0:0003/02/2022 0:00
XS3G7503/02/2022 0:0003/02/2022 0:00
XS3G7503/02/2022 0:0004/02/2022 0:00
XS3G7513/01/2022 0:0014/01/2022 0:00
NBT3 -513/01/2022 0:0014/01/2022 0:00
N89M 37215/02/2022 0:0011/02/2022 0:00
N89M 37211/02/2022 0:0016/02/2022 0:00
N89M 37216/02/2022 0:0011/02/2022 0:00
N89M 37211/02/2022 0:0018/02/2022 0:00
XS3G7504/02/2022 0:0007/02/2022 0:00
NBT3 -504/02/2022 0:0009/03/2022 0:00
NBT3 -514/01/2022 0:0014/01/2022 0:00
XS3G7514/01/2022 0:0028/01/2022 0:00
N89M 37207/02/2022 0:0008/12/2021 0:00
XS3G7507/02/2022 0:0007/02/2022 0:00
XS3G7507/02/2022 0:0030/03/2022 0:00
NBT3 -514/01/2022 0:0021/01/2022 0:00
NBT3 -521/01/2022 0:0026/01/2022 0:00
N89M 37208/02/2022 0:0008/02/2022 0:00
N89M 37218/02/2022 0:0018/02/2022 0:00
N89M 37208/02/2022 0:0009/02/2022 0:00
N89M 37218/02/2022 0:0018/02/2022 0:00
N89M 37218/02/2022 0:0025/02/2022 0:00
N89M 37209/02/2022 0:0010/02/2022 0:00
N89M 37210/02/2022 0:0011/02/2022 0:00
N89M 37207/03/2022 0:0030/05/2022 0:00
N89M 37225/02/2022 0:0028/02/2022 0:00
NBT3 -526/01/2022 0:0002/02/2022 0:00
NBT3 -509/03/2022 0:0009/03/2022 0:00
N89M 37228/02/2022 0:0002/03/2022 0:00
NBT3 -509/03/2022 0:0009/03/2022 0:00
NBT3 -509/03/2022 0:0015/03/2022 0:00
N89M 37202/03/2022 0:0002/03/2022 0:00
N89M 37202/03/2022 0:0002/03/2022 0:00
N89M 37202/03/2022 0:0004/03/2022 0:00
NBT3 -515/03/2022 0:0009/03/2022 0:00
XS3G7528/01/2022 0:0031/01/2022 0:00
N89M 37204/03/2022 0:0007/03/2022 0:00
NBT3 -509/03/2022 0:0021/03/2022 0:00
XS3G7501/04/2022 0:0001/04/2022 0:00
XS3G7501/04/2022 0:0005/04/2022 0:00
NBT3 -501/04/2022 0:0001/04/2022 0:00
NBT3 -501/04/2022 0:0006/04/2022 0:00
XS3G7505/04/2022 0:0005/04/2022 0:00
XS3G7505/04/2022 0:0005/04/2022 0:00
XS3G7505/04/2022 0:0005/04/2022 0:00
XS3G7505/04/2022 0:0008/04/2022 0:00
NBT3 -506/04/2022 0:0006/04/2022 0:00
NBT3 -506/04/2022 0:0007/04/2022 0:00
NBT3 -507/04/2022 0:0008/04/2022 0:00
XS3G7505/05/2022 0:0006/06/2022 0:00
NBT3 -508/04/2022 0:0008/04/2022 0:00
NBT3 -508/04/2022 0:0008/04/2022 0:00
XS3G7508/04/2022 0:0008/04/2022 0:00
XS3G7508/04/2022 0:0008/04/2022 0:00
NBT3 -508/04/2022 0:0008/04/2022 0:00
NBT3 -508/04/2022 0:0011/04/2022 0:00
NBT3 -511/04/2022 0:0023/05/2022 0:00
XS3G7508/04/2022 0:0011/04/2022 0:00
XS3G7511/04/2022 0:0005/05/2022 0:00
NBT3 -523/05/2022 0:0009/04/2022 0:00
NBT3 -521/03/2022 0:0021/03/2022 0:00
NBT3 -509/04/2022 0:0017/05/2022 0:00
NBT3 -517/05/2022 0:0017/05/2022 0:00
NBT3 -517/05/2022 0:0002/06/2022 0:00
N89M 37202/06/2022 0:0003/06/2022 0:00
NBT3 -502/06/2022 0:0023/06/2022 0:00
N89M 37203/06/2022 0:0027/12/2046 0:00
N89M 37230/05/2022 0:0030/05/2022 0:00
XS3G7513/06/2022 0:0015/06/2022 0:00
N89M 37230/05/2022 0:0002/06/2022 0:00
NBT3 -521/03/2022 0:0001/04/2022 0:00
XS3G7506/06/2022 0:0010/06/2022 0:00
XS3G7515/06/2022 0:0015/06/2022 0:00
XS3G7515/06/2022 0:0020/06/2022 0:00
NBT3 -523/06/2022 0:0024/06/2022 0:00
NBT3 -524/06/2022 0:0030/06/2022 0:00
NBT3 -530/06/2022 0:0024/06/2022 0:00
XS3G7520/06/2022 0:0020/06/2022 0:00
XS3G7520/06/2022 0:0020/06/2022 0:00
XS3G7520/06/2022 0:0006/07/2022 0:00
XS3G7530/03/2022 0:0030/03/2022 0:00
NBT3 -524/06/2022 0:0030/06/2022 0:00
NBT3 -530/06/2022 0:0024/06/2022 0:00
NBT3 -524/06/2022 0:0030/06/2022 0:00
NBT3 -530/06/2022 0:0030/06/2022 0:00
XS3G7530/03/2022 0:0030/03/2022 0:00
NBT3 -530/06/2022 0:0030/06/2022 0:00
XS3G7530/03/2022 0:0031/03/2022 0:00
NBT3 -530/06/2022 0:0030/06/2022 0:00
NBT3 -530/06/2022 0:0001/07/2022 0:00
NBT3 -501/07/2022 0:0027/12/2046 0:00
XS3G7531/03/2022 0:0001/04/2022 0:00
XS3G7506/07/2022 0:0007/07/2022 0:00
XS3G7507/07/2022 0:0007/07/2022 0:00
XS3G7507/07/2022 0:0007/07/2022 0:00
XS3G7512/07/2022 0:0013/07/2022 0:00
XS3G7507/07/2022 0:0008/07/2022 0:00
XS3G7513/07/2022 0:0027/12/2046 0:00
XS3G7508/07/2022 0:0012/07/2022 0:00
XS3G7510/06/2022 0:0013/06/2022 0:00
1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

NETWORKDAYS() will only return the number of workdays between start date and end date than each month.

To get the result you want, please try this.

 

1 add one more column in date table via Month = [date].[month]

 

2 create a new calcualte table via 

Table_month = filter(CROSSJOIN('Table','Date'),[Date]>=[Starting Date] && [Date]<=[Ending date])

to expend each date between starting date and ending date.

 

3 create a measure to count how mang days are there during starting and ending date.
countrows('Table_month')


Result:

vchenwuzmsft_0-1658455289823.png

 


Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

1 REPLY 1
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

NETWORKDAYS() will only return the number of workdays between start date and end date than each month.

To get the result you want, please try this.

 

1 add one more column in date table via Month = [date].[month]

 

2 create a new calcualte table via 

Table_month = filter(CROSSJOIN('Table','Date'),[Date]>=[Starting Date] && [Date]<=[Ending date])

to expend each date between starting date and ending date.

 

3 create a measure to count how mang days are there during starting and ending date.
countrows('Table_month')


Result:

vchenwuzmsft_0-1658455289823.png

 


Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

 

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.