Display different columns based on parameter values

  • Last update:  2021-10-11
  • I. Overview

    1. Expected effect

    Sometimes we need to select different parameters and present different template content. For example, according to the summary type selected by the radio button group, the query displays different summary reports. As shown below:


    2. Implementation ideas

    Users need parameter widgets to control the display of different columns in the report. There are two ways to achieve this:

    • Method 1: Use conditional attributes to control the report to display different columns.

    • Method 2: Control the report to display different columns through SQL statements.


    II. Example 1: Realize through condition formatting

    1. Prepare data

    New data set ds1:  SELECT * FROM Sales_Volume

    2. Make a template

    Drag the fields of region and salesperson into the cell, and set different sales summation and report style design respectively. As shown below:
     


    3. Add parameter widget

    First add the template parameter type , as shown in the following figure:

    Add a "Radio Button Group"widget and "Search"widget in the parameter panel . The widget name of the radio button group widget istype . Set the Data Dictionary and customize the two options, as shown in the following figure: 


    4. Setting condition formatting

    Select cells A1 and A2, right-click to add Conditional Formatting: set the Row Height to 0, and the Formula Condition to $type!='Region' . Select cells A3 and A4, and also add Conditional Formatting: the Row Height is 0, and the Formula Condition is $type!='Salesperson' . As shown below:  

    Save the template and click "Pagination Preview" to achieve the effect.


    5. Effect preview

    1) PC

    As shown in section I-1 of this article.


    2) Mobile

    The effect on the App side and HTML5 side is shown in the figure below: 


    III. Example 2: Implementation through SQL statements

    1. Create a new general report

    Click " File> New General Report ", as shown in the figure below:


    2. Add parameter widget

    Add "Radio Button Group"widget, name the widget astype , and add "Search Button" as shown in the figure below: 

    3. Prepare data

    Create a new data set ds1:

    SELECT
    ${if(type="Region","Region","Salesperson")} as a,
    sum(Sales_Volume) num
    FROM Sales_Volume
    ${if(type="Region","group by Region","group by Salesperson")}

    The type parameter value defaults to East China , as shown in the following figure:


    4. Make a template

    Drag the a and num fields into the cell, and set the center and drop-down boxes , as shown in the figure below:  


    5. Set widget parameters

    Save the template and click "Pagination Preview" to achieve the effect.


    6. Effect preview

    1) PC terminal

    As shown in section I-1 of this article.


    2) Mobile

    As shown in section II-5 of this article.


    IV. Template download

    1. Example 1: Realization through condition formatting

    The template has been completed, please refer to: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Parameter\Display_different_columns_based_on_parameter_values.cpt

    Click to download the template: Display_different_columns_based_on_parameter_values.cpt


    2. Example 2: Implementation through SQL statements 

    The completed template can be found at: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Parameter\Use_SQL_statements_to_display_different_columns.cpt

    Click to download the template: Use_SQL_statements_to_display_different_columns.cpt


    Attachment List


    Theme: Parameter
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy