Consider a use case where you don't have any influence on the structure of data you get from applications, APIs or other business layers to merge your templates for invoices or other reports.
In the following scenario, an invoice should be created based on JSON data from an ERP system. All invoice items are returned as line items plus a last line item that only contains the total price. The following JSON is used as a data source. In line 23-25, you can see a line item that only contains a price. This is the line in the final document we would like to filter out.
As the total price should be calculated using a formula in the template, the last "line item" is not required. The following screenshot shows the template with the repeating block:
After the data is merged into this template as is, the results show the "empty" line displaying only the total value:
In order to remove this empty line, it is not required to manipulate the data. A merge block filter can be used to filter out the empty line. The block OrderItems is receiving a filter on the column Qty. If this field is empty, the row should not be rendered:
The following screenshot shows the filtered results:
You can download the template and the sample JSON here for your own tests.