Another new task, another pain. I’ve been asked to create a dashboard for Sales. They want the part number product group, last date the part was purchased or manufactured, the job number or PO number, extend costs and vendor, and a few other minor fields.
I created the BAQ following @kcrusen on this post, E10.0 - SubQuery return maximum transaction date (Bin Ex.)
I started with Part and added a sub-query for Purchase transaction using PartTran and filtering for PUR-STK. I linked the two queries and made a calculated filed in the top query for max(PURSTK.PartTran_TranDate).
This worked and I have all the parts listed with the last Purchased date listed next to purchased parts. As soon as I add another filed from my sub-query my BAQ blows up with multiple rows. It seems any iteration of adding another field blows up the BAQ.
Here’s my current Phrase build, I haven’t added the second sub-query for MFG part yet.
And here’s my query phrase:
/*
* 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].[PartNum] as [Part_PartNum],
[Part].[TypeCode] as [Part_TypeCode],
[Part].[ProdCode] as [Part_ProdCode],
[ProdGrp].[ProdGrup_Description] as [ProdGrup_Description],
(max(PURSTK.PartTran_TranDate)) as [Calculated_MaxPurDate]
from Erp.Part as Part
left outer join (select
[ProdGrup].[Company] as [ProdGrup_Company],
[ProdGrup].[ProdCode] as [ProdGrup_ProdCode],
[ProdGrup].[Description] as [ProdGrup_Description]
from Erp.ProdGrup as ProdGrup
group by [ProdGrup].[Company],
[ProdGrup].[ProdCode],
[ProdGrup].[Description]) as ProdGrp on
ProdGrp.ProdGrup_Company = Part.Company
and ProdGrp.ProdGrup_ProdCode = Part.ProdCode
left outer join (select
[PartTran].[Company] as [PartTran_Company],
[PartTran].[PartNum] as [PartTran_PartNum],
[PartTran].[TranQty] as [PartTran_TranQty],
[PartTran].[UM] as [PartTran_UM],
[PartTran].[ExtCost] as [PartTran_ExtCost],
[PartTran].[PONum] as [PartTran_PONum],
[PartTran].[POLine] as [PartTran_POLine],
[Vendor].[VendorID] as [Vendor_VendorID],
[Vendor].[Name] as [Vendor_Name],
[Vendor].[PhoneNum] as [Vendor_PhoneNum],
[PartTran].[TranDate] as [PartTran_TranDate],
[PartTran].[TranNum] as [PartTran_TranNum]
from Erp.PartTran as PartTran
inner join Erp.Vendor as Vendor on
PartTran.Company = Vendor.Company
and PartTran.VendorNum = Vendor.VendorNum
where (PartTran.TranType = 'PUR-STK')
group by [PartTran].[Company],
[PartTran].[PartNum],
[PartTran].[TranQty],
[PartTran].[UM],
[PartTran].[ExtCost],
[PartTran].[PONum],
[PartTran].[POLine],
[Vendor].[VendorID],
[Vendor].[Name],
[Vendor].[PhoneNum],
[PartTran].[TranDate],
[PartTran].[TranNum]) as PURSTK on
PURSTK.PartTran_Company = Part.Company
and PURSTK.PartTran_PartNum = Part.PartNum
group by [Part].[PartNum],
[Part].[TypeCode],
[Part].[ProdCode],
[ProdGrp].[ProdGrup_Description]
order by Part.PartNum >```