Qlik Community

Qlik NPrinting Documents

Documents related to Qlik NPrinting.

Announcements
See why Qlik is recognized as a Leader for the 10th year in a row – and discover how Qlik can help put your business in the lead. Get Report

Conditionally display a label based on the number of rows in a PixelPerfect report

Employee
Employee

Conditionally display a label based on the number of rows in a PixelPerfect report

Reading this tutorial you will learn how to create a label in a PixelPerfect template that will be conditionally displayed based on the number of rows in a table. This is useful, for example, when you want to display a word when the table contains a single row, and the same word in plural when the table contains many rows.

Create a PixelPerfect template as usual and add the details band of a table in it. Then add the Group Footer.

010.png

Drag and drop a Label from the right toolbar into the Group Footer band and align it with with the column. This label will display the number of Salesmen (so when the table contains more than one row).

020.png

Open the smart tag of the label by clicking on the upper right corner arrow. Expand the Data Binding drop down menu and select the column Salesman. Then click on the three dots on the right of Summary to open the related window.

030.png

In the Summary function select Count and in the Summary running radio button select Group.

040.png

Click on the three dots on the right of Format string. In the General Category enter " Salesmen" in the Suffix form. Note the space at the beginning of the string. Then confirm with OK two times.

050.png

Scroll down the label property grid and set Visible to No

060.png

So the label is created but it is invisible. Now we will create a formatting rule that makes the label visible only when there are more than one row in the table. Open the formatting rules editor by clicking on the dots.

070.png

Click on Edit Rule Sheet then click on the green plus button to open a new rule in the editor. Give a meaningful name to the rule, like Many. Then open the Condition Editor and insert the formula 

Iif([CH192_Level - Top 10 Salesman].Count() > 1, True , False)

 It returns the boolean True only when the table has more than 1 row. Confirm with OK.

080.png

Set the Visible parameter to YES. So when the condition is met it will return true and the formatting rule applied. The formatting rule makes the label visible.

090.png

Click on Close and associate the formatting rule with the label by selecting it and pressing the > button. Then click on OK.

100.png

Run a report Preview in a case with many lines and the label is visible. 

110.png

Add a filter to the report in order to select a single table row and run a new report preview. The label disappears.

120.png

Use copy and paste to create a new copy of the same label, then open the smart tag of the new label. Change the format string to Salesman directly in the form. Then open the Formatting Rules editor by clicking on its dots. Remove the Many formatting rule by clicking on the < arrow and create a new rule.

130.png

Call the new rule One, set Visible to Yes and insert the Condition formula:

Iif([CH192_Level - Top 10 Salesman].Count() == 1, True , False)

It is the same as before a part the equal symbol ==. It returns true when the table has a single row.

140.png

Close the editor and apply the new One rule to the label. Confirm with OK. Run a report preview. You will see the second created label. 

150.png

Now you have two labels, one appears when there is a single row in the table and the second appears when the tables has many rows. Overlap the two labels so the will appear always in the same position in the generated reports.

160.png

Now generated reports will have the correct string based on table rows number.

 

Comments
nandraja
New Contributor

Hi Ruggero,

 

Thanks for reply. The above solution is working  in PDF but my output file is in XLSx it is not showing suffix.

Can you please suggest is there anything other setting i need to do in xls for suffix.

 

Thanks in advance.

 

 

0 Likes
Employee
Employee

Hi,

If you need and output in Excel, I suggest you to develop and Excel template, not a PixelPerfect. Then please open a specific question in the community.

Best Regards,

Ruggero

0 Likes
Version history
Revision #:
1 of 1
Last update:
‎2019-11-21 09:41 AM
Updated by:
 
Contributors