I have done something very similar to this (prior to Named Queries), however, I think the way to achieve this is to structure the query in a way you can give a generic value to the query and it return all data.
I will use MS SQL because you haven’t specified and it’s what I am the most versed in as an example:
WHERE OrderID LIKE ?
If you structure the query in this manner then setting the parameter to the wildcard character (in the case of MS SQL it’s ‘%’ will return all data from the table, but if you set the parameter to a specific value then only that data will be returned.
Obviously this is a simple example and not the only way to achieve what you’re looking for but with the information provided its about as good as I can do.
Another option would be to filter the database via script and manually loading the data in to the chart.
I’m still on 7.9.3 so named queries are not available for me yet. One day I’ll be able to convince them to let me upgrade it, but alas not yet.
Some information that will help others better answer your questions:
What version of Ignition are you using?
What database are you using (MS SQL, MySQL, etc…)