Managing PixelPerfect conditional output using formatting rules
You can use formatting rules to conditionally change the format of objects in a PixelPerfect report. For example, you can create a report that shows a chart only for each country where the sales are more than a selected threshold. You can also highlight cells in a table that match specific conditions.
When using formatting rules, you set criteria by using a formula, and then create a related format. The format that you specified is applied when the formula is true. A rule can be associated with many different objects on the same report, and you can also associate many rules to the same report object.
We recommend using the built-in formula editor to avoid errors when creating the criteria formulas.
Create a new filter
First create a new filter before creating the report. Filters must be created before they can be applied to a report.
Do the following:
- Click Filters under the Apps menu.
- Click Create filter to create a new filter.
- Enter a name for the filter.
- Select an app from the App drop-down list.
- Click Create to create the filter.
- Click Fields.
- Click Add field.
- Select the Connection to the QlikView document that contains the object you want.
- Select Salesman from the Name drop-down list.
- Select Value is from the drop-down list in the Values pane.
-
Select an existing user in the right box.
To learn how to create users, see: Creating users.
- Click Create to confirm.
Create new PixelPerfect report
Do the following:
- Select Reports in the Qlik NPrinting main menu, and then click Create report.
- Enter a Title for the report. PixelPerfect Report Conditional Table Display.
- Select PixelPerfect from the Type drop-down list.
- Select an app from the App drop-down list.
- Click Create to create the report.
Apply the filter
Do the following:
- In the report window, click Filters.
- Move the filter you created earlier from Available Items to Selected Items.
- Click Add Filters.
- Click Overview to return to report overview window.
Create a new PixelPerfect report template
Do the following:
- Click Edit template to open the Template Editor.
- Right-click the Levels node, and select Add levels.
Insert a QlikView table as a level
Do the following:
- Select the Connection to the QlikView document that contains the object you want.
- Select Sales by Country - CH304 from the objects list.
- Click OK.
Change the visible property in the details band
Do the following:
- Create a new table, as you would normally in a PixelPerfect report, based on CH304.
- Select DetailReport - "CH304_Level".
- Change the Visible property from Yes to No.
The detail band will not normally be visible. The formatting rule will make the band visible only for countries with sales over the selected threshold.
Create new rule and apply it to the table
This form shows all the available rules in a report.
Do the following:
- Click the smart tag arrow > of the Detail1 band.
-
Click the three dots on the right of Formatting Rules.
The Formatting Rules Editor window appears.
- Click Edit Rule Sheet to open the Formatting Rule Sheet Editor.
- Click the + button to add a new rule.
- Select CH304_Level from the Data Member drop-down list.
-
Click the Condition form, and then open the Conditional Editor by clicking on the dots that appear on the right.
In the bottom left column, you can see the list of categories of objects that you can use to create the condition
- Click on Fields to see the list of fields available in the Data Member.
- Double-click Sales to add it to the condition.
- Click on the > symbol to add it.
-
Type 30000, so the final formula will be [Sales] > 30000.
Only charts related to countries with sales over 30000 will be displayed.
-
You can also insert [Sales] > 30000 by typing it in the Condition property.
-
Set the Visible property to Yes from the drop-down list.
The objects with the condition applied will be made visible when the condition is true.
- Click OK to confirm the condition.
-
Enter ShowSalesOverThreshold as the Name.
Use a meaningful name for when you need to maintain the report template. Spaces are not allowed.
- Click Close.
Apply the formatting rule to the report object
Do the following:
- Click on ShowSalesOverThreshold in the Rules available in a report column to select it.
-
Move the rule to the Rules applied to a control column by clicking on the > arrow.
Only formatting rules added to this column will be applied to the control.
- Click OK.
Add the chart as an image
Do the following:
- Add the Sales by Categories - CH212 to the Images node.
- Increase the height of the Detail1 band by selecting the bottom border line and dragging it down.
- Drag and drop the CH212 into the Detail1 band, and then enlarge its dimensions by selecting and dragging the bottom right corner.
- Click the smart tag arrow > to open the Picture Box Tasks.
- Select Squeeze from the Sizing drop-down list to fill the available space with the chart image.
- Close the Picture Box Tasks window by clicking on the template area.
Preview and save
Do the following:
- Click Preview.
- Check the report, close it, and then edit the template again if necessary.
- Click Save and Close to save the template and close the Template Editor.