Pentaho Report Designer.pdf
May 9, 2017 | Author: naua2010 | Category: N/A
Short Description
Download Pentaho Report Designer.pdf...
Description
PRD Advanced Concepts
•
© 2013, Pentaho. All Rights Reserved. www.pentaho.com.
Conditional Hide Report Elements To hide report elements based on certain conditions, we can define a formula under 'Style' -> 'visible'. One interesting use case is to hide the labels of the report if no data is returned. For example, to hide all labels of the report if the field 'field1' has a null value: Add a sub-band on the report and insert the labels that you want to hide in the subband. Thus we will not have to define the same formula for each label, but rather only for the sub-band. Highlight the sub-band and go to 'Style' -> 'visible' properties. Add the following formula =IF(ISNA([field1]);"False";"True")
We could also hide the report elements based on whether we have entered a value for a user parameter or not. Highlight the report element and go to 'Style' -> 'visible' properties
Enter the below formula =IF(LEN([param1])=0;"False"; "True") where param1 is the parameter name. •
© 2013, Pentaho. All Rights Reserved. www.pentaho.com.
• US and Worldwide: +1 (866) 660-7555
Invisible Consumes Space If the requirement is that invisible elements on the report should not consume any space in row or column, use the banding element and the
functionality 'invisible consumes space'. This function only works with row banding. Use a band element and under 'Style' define the layout as row or block. If you use the 'block' layout in the
band element, then all elements withing the band will be stacked 'on top of each other'. If one of the elements will be set invisible (e.g. by using a formula in the 'visible' style element), it will not leave a blank space on the report. Same functionality can be used for the 'row' style. In this case the invisible elements will not consume any space in rows. If you intend to remove both spaces for invisible elements (in rows and columns) use two bands one within another, with different layouts 'row' and 'block'. •
© 2013, Pentaho. All Rights Reserved. www.pentaho.com.
• US and Worldwide: +1 (866) 660-7555
Calculate Date Sometimes it is very useful to use a calculated earlier date (e.g. yesterday, a month ago) as a default parameter value on a report. For example, if you
want a report to run every day for the previous day, you might want to add a calculation of 'yesterday' for the default value of the parameter.
To calculate 'yesterday' in the report designer use the following formula in the 'default value formula' or 'post processing formula' of the parameter: =DATEVALUE(DATE(YEAR(TODAY()-1);MONTH(TODAY()-1);DAY(TODAY()-1)))
To calculate '12 month ago' in the report designer use the following formula in
the 'default value formula' or 'post processing formula' of the parameter: =DATEVALUE(DATE(YEAR(TODAY());MONTH(TODAY())-12;DAY(TODAY()))) •
© 2013, Pentaho. All Rights Reserved. www.pentaho.com.
• US and Worldwide: +1 (866) 660-7555
Configure JNDI for Pentaho Report Designer It is recommended to use JNDI connection on the Pentaho BI server for security purposes and to simplify the maintenance of the connection details for the reprorts. For the report to reference the JNDI connection as configured in the Enterprise Console, JNDI connection needs to be referenced in the Report Designer, before the report is published to the server. To be able to preview your report in the Report Designer using JNDI connection, you will need to configure the connection details.
The JNDI connections for the Pentaho Report Designer are configured in the following file: .pentaho\simple-jndi\default.properties Add your connection details in this file and you will be able to connect to the data using the JNDI name in the Report Designer.
As an example, use the following format to define a new JNDI connection SampleJNDIName/type=javax.sql.DataSource SampleJNDIName/driver=com.mysql.jdbc.Driver SampleJNDIName/user=SampleUser SampleJNDIName/password=SamplePassword SampleJNDIName/url=jdbc:mysql://localhost:3306/SampleData •
© 2013, Pentaho. All Rights Reserved. www.pentaho.com.
• US and Worldwide: +1 (866) 660-7555
Set parameter value on user log in In the example below we will determine the value of the location parameter depending on the user log in. If you want the user to see a certain report for their location only, this is the way to do it. Assuming you are storing the user names and corresponding locations in a data base table called dim_user (mysql dump attached) Add a query to your report to retrieve the location of the user. To identify the login of the user ${env::username} in your query select * from dim_user where username=${env::username}
Add a parameter to your report and configure as shown. Make sure you set the post-processing formula (this is setting the value of the parameter) and tick "Use first value if default value formula results in N/A" You can make this parameter hidden as it does not require any user input - tick "Hidden".
•
© 2013, Pentaho. All Rights Reserved. www.pentaho.com.
• US and Worldwide: +1 (866) 660-7555
Dynamic SQL in Report Designer We can inject parameters into the SQL query in the Report Designer using the syntax
SELECT ${param1} FROM ${param2} WHERE field=${param3}
It is also possible to change the SQL statement completely, based on user's selection. With this option we can determine the query behaviour based on some
parameterization (i.e. Fields in select statement, sorting/grouping etc) Let’s see an example:
•
© 2013, Pentaho. All Rights Reserved. www.pentaho.com.
• US and Worldwide: +1 (866) 660-7555
Dynamic SQL in Report Designer * Create a table dataset
•
© 2013, Pentaho. All Rights Reserved. www.pentaho.com.
• US and Worldwide: +1 (866) 660-7555
Dynamic SQL in Report Designer * Create a parameter associated to the table dataset
•
© 2013, Pentaho. All Rights Reserved. www.pentaho.com.
• US and Worldwide: +1 (866) 660-7555
Dynamic SQL in Report Designer * Create a JDBC Custom query
... And choose the JDBC data source
•
© 2013, Pentaho. All Rights Reserved. www.pentaho.com.
• US and Worldwide: +1 (866) 660-7555
Dynamic SQL in Report Designer * Define the dynamic query associated to the master report First define the “template” for your query (it will be used to know which kind of fields are in the report)
•
© 2013, Pentaho. All Rights Reserved. www.pentaho.com.
• US and Worldwide: +1 (866) 660-7555
Dynamic SQL in Report Designer * Define the dynamic query associated to the master report Then define the query as an expression “injecting” the name of the parameter
•
© 2013, Pentaho. All Rights Reserved. www.pentaho.com.
• US and Worldwide: +1 (866) 660-7555
View more...
Comments