How to Display One of Two Tables Based on a Parameter Selection in Helical Insight Canned Reporting?

Hello Team,

In Helical Insight Canned Reporting, we have two Table components that use different queries and may have different column configurations.

We want to display only one table based on the value selected by the user through a report parameter.

For example:

When the user selects a particular parameter value, the first table should be displayed.

When the user selects any other value, the second table should be displayed.

Both tables should occupy the same position in the report rather than appearing one below the other.

Thank You,
Snow.

Hello Snow,

Create two separate queries (Query1 and Query2) according to the required table layouts. For this below example, both queries use the travel_details table and the TravelMedium parameter.

SELECT *
FROM "travel_details"
WHERE "travel_medium" = ${TravelMedium}

Use the appropriate query for each table. The queries can return different fields or use different source tables, provided each table is mapped to its intended query. Both the queries should have a filter to which it will be listening to and on the same we will implement hide/show logic.

image

  1. Create the parameter

Create a parameter named TravelMedium. For the example, its available values can be populated using:

SELECT DISTINCT "travel_medium"
FROM "travel_details"

image

The parameter should be available to both queries.

Further reading about parameters.

  1. Configure the first table

Select the first Table component and enter the following expression in its PrintWhen Expression property (To know more about table component please refer to this blog : Usage of Table Component in canned Reporting - Helical Insight )

image

Printwhenexpression :“Bus”.equalsIgnoreCase($P{TravelMedium})

This expression displays the first table only when the selected TravelMedium value is Bus.

  1. Configure the second table

Select the second Table component (if you have any condition you can right it on print when expression). For now I am keeping in our case empty.

This expression displays the second table whenever the selected value is not Bus.

  1. Add and position the two tables

Add two Table components to the canvas. Map the first table to Query1 and the second table to Query2. Place the second table directly over the first table at the same canvas position. Do not place the second table under the first one; overlapping their positions allows the applicable table to use the same report area.

image

  1. Save and preview

Save the report and test it with different parameter selections. Confirm that only the expected table is rendered and that both components occupy the same position.

image

Preview when Bus is selected: the first table is displayed.

image

Preview when another value is selected: the second table is displayed

In a similar way we can have many components, which can be displayed, hidden based on the filter value and the condition written in PrintWhenExpression. This PrintWhenExpression can be applied on any component.

Thank You,
Helical Insight