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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Measure to determine time range

How to create a measure to determine if the truck is working(goods delivered) during the window --> (3am to 1pm) ?

I have data for 3 months/20 trucks in the below format and would like to create a report page that shows the performance of the truck by the percentage of times the truck has finished delivery within the above time window or not.

 

TruckGoods deliveredCustomerDate
Truck 11:45a9/02/2021
Truck 114:00b9/02/2021
Truck 23:45c10/12/2021
Truck 24:45d10/12/2021

 

for example - truck 1 has failed to deliver within the given time window(3am to 1pm), the output should be like below.

truck 1 - 0% and truck 2 - 100%

 

Any help would be greatly appreciated! Thank you.

1 ACCEPTED SOLUTION

@Anonymous , Try a measure like

divide(countx(filter(summarize(Table, Table[Truck], "_1",calculate(coutrows(Table), filter(Table,Table[Goods delivered] >=time(3,0,0) && Table[Goods delivered] <=time(13,0,0))),"_2",coutrows(Table)), [_1] =[2]),[Truck]) , distinctcount(Table[Truck]),0)

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Mrugankjoshi_0-1612843075484.png

 

@Anonymous , Try a measure like

 

divide(calculate(coutrows(Table), filter(Table,Table[Goods delivered] >=time(3,0,0) && Table[Goods delivered] <=time(13,0,0))),coutrows(Table))

Anonymous
Not applicable

Sorry i should have been more clear on my requirement.

 

We have business requirement as below example.

 

If truck xyz fails to deliver within given time window.. even for 1 customer then it'll be 0% performance for given day. 

@Anonymous , Try a measure like

divide(countx(filter(summarize(Table, Table[Truck], "_1",calculate(coutrows(Table), filter(Table,Table[Goods delivered] >=time(3,0,0) && Table[Goods delivered] <=time(13,0,0))),"_2",coutrows(Table)), [_1] =[2]),[Truck]) , distinctcount(Table[Truck]),0)

Anonymous
Not applicable

Thank you! that works perfectly. 

 

I'm trying to understand but not sure of some of the functions used in the above solution, can I please get a brief overview of how these functions work all together to provide the output?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors