BAQ Table Criteria: Using field=expression

I’ve written a million BAQs but I have never figured out how to use the Field=Expression in Table Criteria. When I click on Expression, it brings up a window which says “Specify SQL Expression” and regardless of what I put in there the BAQ fails.

What I am trying to use this for is to create a BAQ that only shows parts which exist in a list of 350 parts, so I am thinking something like ‘123’ OR ‘234’ OR ‘456’ etc. I realize that there is a BAQ operand IN which lets me specify list values, but you can’t copy/paste into that screen and I don’t want to enter 350 list items manually one-by-one.

What is the best way to handle filtering based on a list like this?

If it were me, I would probably load the list via DMT into a UD table, and then join on that table. Maybe not the best way, but it’s a way. Also, depending on the further use case, you use you user codes and load them in there via DMT as well, with the benefit that you can easily manipulate that list later. Depends on what you want to do.

Also, if you’re able to use a SQL statement, can’t you do a subquery? Or did you just mean to paste in the list?

1 Like

@aaronssh I have found it works if you use the ‘=’ expression and then use an OR statement in the expression. So to filter on a selected list of PartNums:

‘1’ OR
Part.PartNum=‘2’ OR
Part.PartNum=‘3’ OR
Part.PartNum='4 OR
Part.PartNum=‘5’

MSSQL converts all IN statements to OR statements anyway.

3 Likes

@Banderson is correct. You will want this list defined somewhere other than a bunch of “OR” statements.

Beautiful John! That is exactly what I was needing. I know that I can do the UD table import, but this is one of just many many times that I’ve needed to use a list and I’m thankful to know how to do that easily now.

1 Like

Wow that is good to know. I thought at one point there was a size limit to the criteria field like (256 chars or such). I know there was for the ‘IN’ list.
Which is why i always used the “UD field” method .
But this method is quicker
Nice
Thanks for sharing. :slight_smile:

1 Like

2 posts were split to a new topic: SQL Starts With List