12

Currently, DataItemTableFilter applies after joining two different data items. The work around is to make your filters occur upstream from your joins; however, queries do not support multiple data items in parallel levels. This means there is a functional gap if you have several data items with table filters involved.


I propose one of three solutions:

  1. [Recommended] Add a Data Item attribute that dictates if the DataItemTableFilter applies before or after the join.
  2. Default the DataItemTableFilter to occur before the SQL joining behavior.
  3. [Less recommended] Allow for multiple data items in the same tier.


Until one of these solutions is implemented, I have to run separate queries on similar data sets or scrap queries altogether.

Category: Development
STATUS DETAILS
Needs Votes
Ideas Administrator

Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future. Best regards, Business Central Team

Comments

K

 I would like to emphasize while this is an important improvement from a performance perspective Currently filtering for AL query objects is done by either the DataItemTableFilter or filter columns property. Both of these properties are executed in the background as SQL “WHERE” clauses meaning filtering to happen after the join. This changes the outcome of queries when LeftOuterJoin is used. For example when I need a query that selects Customer Ledger Entries and corresponding detail Ledger Entries with a filter on type “Application”, when there are no applications I still want the Customer Ledger Entry information. When there are no detailed ledger entries the ON clause will give me the Customer Ledger Entry with an empty column for the detailed Ledger Entry. A WHERE clause returns 0 rows. This also applies to aggregates like SUM or COUNTThis quickly becomes a problem for more complex queries where we want to aggregate data from multiple sources that may or may have records. The workaround is to retrieve this data in separate queries but this is inefficient as some data needs to be retrieved twice.Therefore I strongly support suggestion 1 of adding a Data Item attribute that sets the filter order.Proposed parameter:DataItemJoinOrder Permitted values: “WHERE”, “ON”Default value: “WHERE”

Category: Development

K

Being able to filter DataItems before they are joined would really be great. It's a pretty basic feature in SQL, so it should available in AL as well (IMHO).

Category: Development

K

FYI here is an article from MS communities that provides more detail on the undesirable interaction between joins and filters.

Category: Development