Good afternoon, Using E10, Classic UX, and relatively new to BAQs. I am trying to work through average ‘real’ lead time for parts, but we sometimes utilize multiple vendors for the same parts, based on availability. I am getting all the data I need, but cannot decipher how to get the “Average” to show as just one line per Vendor/Part (grouped). I have tried a number of things, but either get syntactical error, or no modification to the results. Here is what I have so far:
‘’'/*
- Disclaimer!!!
- This is not a real query being executed, but a simplified version for general vision.
- Executing it with any other tool may produce a different result.
*/
select
[Part].[ClassID] as [Part_ClassID],
[Part].[PartNum] as [Part_PartNum],
[Part].[PartDescription] as [Part_PartDescription],
[Vendor].[VendorID] as [Vendor_VendorID],
[SubQuery2].[RcvDtl_VenPartNum] as [RcvDtl_VenPartNum],
[PODetail].[PONUM] as [PODetail_PONUM],
[PORel].[POLine] as [PORel_POLine],
[PORel].[PORelNum] as [PORel_PORelNum],
[POHeader].[OrderDate] as [POHeader_OrderDate],
[SubQuery2].[RcvDtl_ReceiptDate] as [RcvDtl_ReceiptDate],
[PODetail].[UnitCost] as [PODetail_UnitCost],
(datediff(day, POHeader.OrderDate, SubQuery2.RcvDtl_ReceiptDate)) as [Calculated_ActLeadTime],
(AVG(CAST(ActLeadTime AS DECIMAL(10,2))) over (PARTITION BY Part.PartNum, Vendor.VendorID)) as [Calculated_AvgLeadTime]
from Erp.Part as Part
left outer join Erp.PODetail as PODetail on
Part.Company = PODetail.Company
and Part.PartNum = PODetail.PartNum
inner join Erp.POHeader as POHeader on
POHeader.Company = PODetail.Company
and POHeader.PONum = PODetail.PONUM
inner join Erp.Vendor as Vendor on
POHeader.Company = Vendor.Company
and POHeader.VendorNum = Vendor.VendorNum
and ( not Vendor.VendorID = ‘HASKI001’ )
inner join Erp.PORel as PORel on
PODetail.Company = PORel.Company
and PODetail.PONUM = PORel.PONum
and PODetail.POLine = PORel.POLine
and ( PORel.PORelNum = 1 )
inner join (select
[RcvDtl].[PONum] as [RcvDtl_PONum],
[RcvDtl].[POLine] as [RcvDtl_POLine],
[RcvDtl].[PORelNum] as [RcvDtl_PORelNum],
[RcvDtl].[VenPartNum] as [RcvDtl_VenPartNum],
[RcvDtl].[ReceiptDate] as [RcvDtl_ReceiptDate],
[RcvDtl].[ReceivedComplete] as [RcvDtl_ReceivedComplete]
from Erp.RcvDtl as RcvDtl
where (RcvDtl.ReceiptDate >= dateadd (month, -6, Constants.Today) or RcvDtl.ReceiptDate = ‘Null’)) as SubQuery2 on
PORel.PONum = SubQuery2.RcvDtl_PONum
and PORel.POLine = SubQuery2.RcvDtl_POLine
and PORel.PORelNum = SubQuery2.RcvDtl_PORelNum
group by [Part].[ClassID],
[Part].[PartNum],
[Part].[PartDescription],
[Vendor].[VendorID],
[SubQuery2].[RcvDtl_VenPartNum],
[PODetail].[PONUM],
[PORel].[POLine],
[PORel].[PORelNum],
[POHeader].[OrderDate],
[SubQuery2].[RcvDtl_ReceiptDate],
[PODetail].[UnitCost]
order by Part.PartNum, Vendor.VendorID’‘’
Results:
Fairly certain this is pretty easy, and I have just looked at so many post that I can’t see the forest for the trees.
Any help or guidance would be greatly appreciated.
