News combit Dev Blog

Defining Sub Tables via Filter Conditions

Posted: Tuesday, June 25, 2019 | 0 comment(s)
 
This is another great addition to the report container's feature set. Until LL25, related tables always needed to have an actual relation on the data source level in order to be usable as data source for sub items. If there was no relation, there was no way to insert the sub item, even if both tables in question had an ID field that would easily allow a custom linkage. In LL25, you can now have relations based on filter conditions.

A typical use case: think of an SQL database where the relations are not set on the server level (which happens more often than never) or two loosely related tables where the key might be a combination of a couple of fields. Or you have a mixed data source, e.g. a CSV file and an XML file that are coupled via an ID field. While for the latter case there has been a code based solution around for a while, this new feature lives entirely in the Designer. The performance heavily relies on filtering at database level - it is strongly suggested to use only database-translatable filters when using this new feature.

You can even define virtual relations, e.g. based on dates using this feature. Let's do a quick walkthrough. For this sample, we'll be using Microsoft's Contoso sample database for SQL Server. Did you know the demo application is capable of binding to any SQL datasource? Just choose "Custom Data Sources" and find yourself in the well known realm of the DataConnection UI that allows to connect to ODBC, Oracle or MS SQL data. 

Connecting to the ContosoRetailDW database is simple then:



For a simple sample of a virtual relation let's design a report of all the employees in the DimEmployee table and - per employee - all the customers from the DimCustomer table that happen to be born on the same day. The first step is easy, just drop some fields like FirstName, LastName and BirthDate from the DimEmployees table to the workspace to get the employee list. Next, click on "Append a Sub-Element" in the object tool window in order to add the DimCustomer table underneath. In the schema, there is no direct relation between the two tables, so choose "Link via Filter" from the new UI:


 

This allows to select from all the tables in the database (except the one you're starting from). Select the DimCustomer table here and continue, select some fields for the customer database from the field selection wizard and go ahead. A message box pops up with a short description of what's important to know when entering the filter condition in the next step. 


 

Assigning the required filter is dead easy in this case, of course. Note that the filter can be carried out on the database system in this case:


 

And printing the report nicely displays all the customers with the same birthday, highly performant. The "Demo" watermark is added in the demo application whenever you choose "Custom Datasource" as it would be too tempting to just use the trial version as a fully fledged SQL reporting system ;).

If you're not using one of our components, you might have to adapt your printing code a bit in order to work with an empty relation name returned by LlPrintDbGetCurrentTableRelation() for a sub table. However, the required changes are quite easy to make (simply return the "full" child table in this case, filtered by the result of LlPrintDbGetCurrentTableFilter). And as one of the first questions whenever we add something new is "can this be switched off(wink): Yes, it can (LL_OPTION_COMPAT_PROHIBITFILTERRELATIONS).

 

What are your ideas for virtual relations? Can this solve some real life pain on your end as well?




Author: Jochen Bartlau
Head of Development List & Label

Jochen Bartlau leads the development at combit as Managing Director. He's a Microsoft .NET enthusiast driving innovation & agile project management. The mobile devices geek who used to be a physicist in his first life loves to spend his spare time with his family.


  

RSS
combit Development BlogRSS
What’s this blog for?
A place to share updates about the ongoing development of our products. General musings on the software industry included.
Archive
June 2021 (1)
May 2021 (1)
April 2021 (2)
March 2021 (1)
February 2021 (2)
January 2021 (1)
December 2020 (2)
November 2020 (1)
October 2020 (2)
September 2020 (1)
August 2020 (2)
July 2020 (1)
June 2020 (1)
May 2020 (2)
April 2020 (2)
March 2020 (2)
February 2020 (1)
January 2020 (1)
December 2019 (1)
November 2019 (2)
October 2019 (2)
September 2019 (2)
August 2019 (2)
July 2019 (2)
June 2019 (2)
May 2019 (1)
April 2019 (0)
April 2019 (1)
March 2019 (1)
February 2019 (1)
January 2019 (1)
December 2018 (1)
November 2018 (2)
October 2018 (4)
September 2018 (4)
August 2018 (2)
July 2018 (2)
June 2018 (2)
May 2018 (1)
April 2018 (1)
March 2018 (1)
February 2018 (2)
January 2018 (1)
December 2017 (1)
November 2017 (2)
October 2017 (3)
September 2017 (3)
August 2017 (2)
July 2017 (2)
June 2017 (1)
May 2017 (2)
April 2017 (1)
March 2017 (1)
February 2017 (1)
January 2017 (2)
December 2016 (1)
November 2016 (1)
October 2016 (4)
September 2016 (5)
August 2016 (2)
July 2016 (2)
June 2016 (3)
May 2016 (2)
April 2016 (3)
March 2016 (3)
February 2016 (1)
January 2016 (2)
December 2015 (2)
November 2015 (1)
October 2015 (4)
September 2015 (5)
August 2015 (2)
July 2015 (2)
June 2015 (2)
May 2015 (1)
April 2015 (2)
March 2015 (1)
February 2015 (1)
January 2015 (1)
December 2014 (2)
November 2014 (1)
October 2014 (1)
September 2014 (2)
August 2014 (1)
July 2014 (2)
June 2014 (1)
May 2014 (2)
April 2014 (1)
March 2014 (2)
+1 800 256 3608 (toll-free North America only)