Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Report with condition in a field. Topic is solved

Questions related to nuBuilder Forte Reports and the Report Builder.
Post Reply
pedromiceli
Posts: 5
Joined: Thu Mar 16, 2023 1:37 pm

Report with condition in a field.

Unread post by pedromiceli »

Hello Friends, I have a report, in my report i have some columns one of them is the "STATUS" column, and there only two options on this column "FAILURE" or "OK".
My question is, there is a way to change the background of this field with a condition on the report pdf? for example: if "FAILURE" background red else background green?
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Report with condition in a field.

Unread post by kev1n »

You should be able to achieve conditional formatting this way:

http://wiki.nubuilder.net/index.php/Rep ... lder#Field
pedromiceli
Posts: 5
Joined: Thu Mar 16, 2023 1:37 pm

Re: Report with condition in a field.

Unread post by pedromiceli »

kev1n wrote: Fri Mar 31, 2023 5:33 am You should be able to achieve conditional formatting this way:

http://wiki.nubuilder.net/index.php/Rep ... lder#Field
Hi Kev1n thanks for your help, i red the link but i couldnt understand how to do this.

Conditional formatting is available in nuBuilder for changing the background and font color of a Field Object.

By prefixing a value with 10 characters eg. '#B#66FF99|' will change the background color to #66FF99 (red).
By prefixing a value with 10 characters eg. '#F#FF0000|' will change the font color to #FF0000 (light green).
By prefixing a value with 20 characters eg. '#B#66FF99|#F#FF0000|' will change both font and background colors.

How do i prefix a value? In object Properties in the nuReport Designer?
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Report with condition in a field.

Unread post by kev1n »

Either use a procedure as shown in the linked example or

1. Create an SQL with the SQL Builder like:
sql_builder.png

Code: Select all

SELECT
   if ( STATUS = 'OK', CONCAT('#B#F5B7B1|', STATUS), CONCAT('#B#D5F5E3|', STATUS )) as STATUS ,
   other_column_1,
   other_column_2
FROM
    your_table
The SQL query selects data from a table called "your_table" and returns three columns: "STATUS", "other_column_1", and "other_column_2". (change accordingly)
The value of the "STATUS" column is conditionally formatted based on the value of the "STATUS" field in the table.

If the "STATUS" field is equal to 'OK', the background color of the "STATUS" field will be set to #F5B7B1 (a light shade of red)
If the "STATUS" field is not equal to 'OK', the background color of the "STATUS" field will be set to #D5F5E3 (a light shade of green)

The formatting is achieved by concatenating the appropriate prefix and value to the value of the "STATUS" field using the CONCAT function. The resulting formatted value is then assigned to the "STATUS" column for display.

2. and in the Report Builder, use that nuSQL:
report_builder.png
You do not have the required permissions to view the files attached to this post.
Post Reply