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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
GMadd
Helper I
Helper I

OTIF For Multiple Line Orders

I have been trying all day how to calculate OTIF for customer orders when there is multiple lines on the order. If one of the lines is short on a three line order the entire is considered short and not on time. I know how to calculate the on-time part by having a formlua to compare the DlvPlnd PGI dt (date to ship) and the Act. Gds Mvmnt Date (date shipped). Also, know how to calculate if it was shipped in full.  I am stuck on how to calculate the OTIF % based for each Delivery considering if one of the lines was short. Keep in mind everything is based off of column "G" Delivery meaning every item on the specifed delivery always shipped together. I know the data in the screen shot is in excel but I am wanting to write a DAX measure to handle this in Power BI. Thank you for your help.

GMadd_0-1703027520119.png

 

2 REPLIES 2
GMadd
Helper I
Helper I

Few questions

I could not get your measure for counting deliveries to work:

Total_Orders = CALCULATE(COUNTROWS('OTIF Table'), FILTER('OTIF Table', [Delivery] = MAX([Delivery])))

I used 

Total_Orders = CALCULATE(DISTINCTCOUNT(OTIF[Delivery])) and it gave me the desired result.
 
Second question 
Not sure I understand what the value should be. In my full report it produced a value of "1"

 is this the desired result?

on time in full = var _count1=COUNTROWS(FILTER(ALLSELECTED('OTIF Table'),[Delivery]=MAX('OTIF Table'[Delivery])))
var _count2=COUNTROWS(FILTER(ALLSELECTED('OTIF Table'),[On-Time]="Yes"&&[Full]="Yes"&&[Delivery]=MAX('OTIF Table'[Delivery])))
return IF(_count1=_count2,1,0)

 Thank you for responing so quickly.

Anonymous
Not applicable

Hi @GMadd 

 

I have understood about your problem, here is the solution I offer:

 

The data from the screenshot you provided is used here

vnuocmsft_0-1703063310193.png

 

First, calculate the total number of orders after removing duplicate values

vnuocmsft_1-1703063327851.png

 

Total_Orders = CALCULATE(COUNTROWS('OTIF Table'), FILTER('OTIF Table', [Delivery] = MAX([Delivery])))

 

 

Then calculate the number of orders when both on-time and full are "yes", and deduplicate:

 

_count1 counts the total number of orders grouped by Delivery

_count2 counts the total number of orders that have passed through the Delivery group and meet the filter conditions

If _count1 and _count2 are equal, it is recorded as a record

vnuocmsft_2-1703063372080.png

 

on time in full = var _count1=COUNTROWS(FILTER(ALLSELECTED('OTIF Table'),[Delivery]=MAX('OTIF Table'[Delivery])))
var _count2=COUNTROWS(FILTER(ALLSELECTED('OTIF Table'),[On-Time]="Yes"&&[Full]="Yes"&&[Delivery]=MAX('OTIF Table'[Delivery])))
return IF(_count1=_count2,1,0)

 

 

Count how many order records there are

vnuocmsft_3-1703063418345.png

 

Total on time in full = CALCULATE(DISTINCTCOUNT('OTIF Table'[Delivery]),FILTER('OTIF Table',[on time in full]=1))

 

 

The results of these measures are as follows, which you can understand in conjunction with DAX

vnuocmsft_5-1703063464922.png

 

Finally, calculate the percentage

vnuocmsft_4-1703063439327.png

 

OTIF % = DIVIDE([Total on time in full], [Total_Orders])

 

 

Here is the result

vnuocmsft_0-1703063618175.png

 

Best Regards,

Nono Chen

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

 

 

 

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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