Distinct Doesn't Apply In BAQ Layout Mode

I have a BAQ that shows all operations for a part. Distinct is set at the top level. In BAQ edit mode, the BAQ does not show any duplicates. When I add the same BAQ to my kinetic home page layout, it seems like that Distinct at the top level is ignored, as I get duplicates for some operations. I know how to filter them out. The bigger issue seems to be that the BAQ in a layout doesn’t honor Distinct. Is this a bug?

1 Like

Sounds like a bug to me

2 Likes

Submitted as [CS0005248638]. Thank you!

1 Like

FWIW, I’m not experiencing this behavior (2025.2.7)

select distinct 
	[Part].[CommercialCategory] as [Part_CommercialCategory], 
	[Part].[CommercialSubCategory] as [Part_CommercialSubCategory] 

from Erp.Part as [Part]
order by Part.CommercialCategory
1 Like

Confirmed my version 2025.2.7.
Here is the BAQ in layout view showing the duplicate rows.

And here is the BAQ view showing the correct set of data without those dups.

In this case the dupes are caused by multiple PartOpDtl records. I know that I can fix this by filtering on that table, and we put that in place. But this is still an example of Distinct not working in layout.

Interesting. If any fields from PartOpDtl are included in top-query select list then distinct is working.

You’ve confirmed dupes are indeed not returned in BAQ designer by sorting by Part, Rev, Opr?

I believe Baq Test returns something like Top(1000) rows so you prolly should force OrderBy to confirm it not a mirage.

One would think, if your top-query starts ‘SELECT DISTINCT’ and zero fields from PartOpDtl are in the select list, then what you’re seeing is impossible.

I exported the data from the BAQ editor to Excel to compare the rows. I sorted in Excel and confirm there are no duplicates in the BAQ data. I can’t export the data from the BAQ Layout version. I get this server error:

Program Ice.Services.Lib.RunTask when executing task 1087524 raised an unexpected exception with the following message: RunTask:
System.ArgumentException: ‘’, hexadecimal value 0x1E, is an invalid character.

EDIT: It shows Download complete check notifications. Then in notificatison I see that error.

Part of my BAQ does a replace on line breaks and tabs (chars 9, 10, 13) in the comments field. That is the only thing that I can think of causing that invalid character error.

I can confirm there are no fields from the PartOpDtl table in the output.
Interesting…

Right but do you see this msg in baq test?

If so you’re not getting all rows in your test so excel-check isn’t valid proof.

You can make top(10000) a proof if you set OrderBy.

No. It is pulling all 101,733 records.

1 Like

Wonder if it’s the same on dashboard page and not specifc to layouts.

If so, there’s a diff with respect to DISTINCT between Ice.BO.DynamicQuerySvc/Execute and Ice.BO.KineticErpSvc/ExecuteBaq and maybe pinging Olga in addition to support would be enlightening.

2 Likes