I'm having a heck of a time applying multiple filters to my SQL table. |The data comes from the Dynamics NAV Item table and i'm trying to filter by "Division Code" then "Item Category Code" as well as a search by "No_"
I have two drop down boxes. the first connected to the Division table which has the Columns "Code" (10, 20, 30, etc) and "Description" (Dining, Bedroom, etc) and the second to the Item Category table which has columns "Code" (10-001, 20-004, etc) and "Description" (Benches, Sofas, etc).
After much fighting, I've managed to get the second drop down to filter based on the first with the following code:
Filter(RenameColumns('[dbo].[Item Category]',"Division Code","DivisionCode"),DivisionCode=Dropdown1.Selected.Code)
I needed to add the RenameColumns because I couldn't get the dropdown to populate if the filter columns had a space in the name.
Now I'm trying to filter a gallery connected to the Item table which has over 5000 records, therefore filtering needs to be done server side. I am again running into issues with column names having spaces in them. and get the following error in my filter:
"The requested operation is invalid.
Server Response: ')' or operator expected at position 10 in (Division Code eq '50')and(Item Category Code eq '50-001')'.
inner exception: ')' or operator expected at position 10 in (Division Code eq '50')and(Item Category Code eq '50-001')'."
It seems as thought the column names are being sent to the query without quotes around them. and the spaces are breaking the syntax.
I've tried to compensate for it in the gallery.Items with the following, but i'm only getting results from the first 500 rows.
SortByColumns(Filter(RenameColumns(RenameColumns('[dbo].[Item]',"Division Code","DivCode"),"Item Category Code","CatCode"), DivCode = Dropdown1.Selected.Code && CatCode=Dropdown2.Selected.Code),"No_",Ascending) How can I get around this query error with spaces in the column names and have the results filtered server-side?
Thanks!