1

I'm trying to make multiple values "Bold" within an expression when the value contains "x". Html Placeholder properties doesn't meet my need and I'm struggling to get it working with the below as there are multiple statements in my expression:

=(IIF(Fields!Test1.Value="x", "Bold", "Normal") OR (Fields!Test2.Value="x", "Bold", "Normal") etc etc

I think I need to create a custom code function then call the function where needed in the expression but I haven't a clue where to start! Any help would be greatly appreciated.

Update:

Switch is working but bolding whole expression not just values specified within Placeholder Properties of expression. I believe this is because my main expression has concatenated fields creating one long string.

Placeholder exp

Result

Value exp

+-----------+------------+-----------+------------------+------------------+-----------+-----------+------------+-----------+-------------------+---------+--------------+-----------+----------------+-------------------------------+-----------------+---------------+--------------+----------+------------------+------------------+------------------+------------------+------------+---+------------+-----------+-------------------+-----------+--------------+-----------+----------------+---------+----------+-------------------+----------------------+---------------+----------------+---------+
| id_number | first_name | last_name | pref_address_ind | h_addr_type_code | h_care_of | h_street1 | h_street2  | h_street3 | h_foreign_cityzip | h_city  | h_state_code | h_zipcode | h_country_code |        h_email_address        | p_email_address |    h_phone    |              | hc_phone | b_company_name_1 | b_company_name_2 | b_business_title | fld_of_work_code | b_street1  |   | b_street2  | b_street3 | b_foreign_cityzip |  b_city   | b_state_code | b_zipcode | b_country_code | b_phone | bc_phone |  b_email_address  |                      | full_business | pref_email_ind | Main_ID |
+-----------+------------+-----------+------------------+------------------+-----------+-----------+------------+-----------+-------------------+---------+--------------+-----------+----------------+-------------------------------+-----------------+---------------+--------------+----------+------------------+------------------+------------------+------------------+------------+---+------------+-----------+-------------------+-----------+--------------+-----------+----------------+---------+----------+-------------------+----------------------+---------------+----------------+---------+
|    165815 | Test       | Test1     | NULL             |                  | NULL      | NULL      | x Apt #09  | NULL      | NULL              | NULL    | NULL         | NULL      | x USA          | NULL                          | NULL            | DELETED       |              | DELETED  | NULL             | ~                | NULL             | NULL             | NULL       |   | NULL       | NULL      | NULL              | NULL      | NULL         | NULL      | NULL           | NULL    | NULL     | NULL              |                      | NULL          | NULL           |  165815 |
|    165816 | Test       | Test2     | NULL             |                  | NULL      | Street    | x Street 1 | x Street2 | NULL              | Houston | NULL         | NULL      | NULL           | x Home Email:testing@test.com | NULL            | x Home Phone: | 111-111-1111 | NULL     | NULL             | ~                | NULL             | NULL             | x Business | 1 | x Street 2 | NULL      | NULL              | x Houston | x TX         | x 77777   | NULL           | NULL    | NULL     | x Business Email: | btesting@testing.com | NULL          | NULL           |  165816 |
+-----------+------------+-----------+------------------+------------------+-----------+-----------+------------+-----------+-------------------+---------+--------------+-----------+----------------+-------------------------------+-----------------+---------------+--------------+----------+------------------+------------------+------------------+------------------+------------+---+------------+-----------+-------------------+-----------+--------------+-----------+----------------+---------+----------+-------------------+----------------------+---------------+----------------+---------+
DHorse1984
  • 15
  • 1
  • 4

1 Answers1

1

There should be no need for custom code although depending on how complex the rules are you may want to consider SWITCH.

Based on your simple example you could do either of these

=IIF(
     Fields!Test1.Value = "x" OR Fields!Test2.Value = "x",
     "Bold", 
     Nothing)

or for a more complex situation

= SWITCH (
          Fields!Test1l.Value = "x" OR Fields!Test2.Value="x", "Bold",
          Feilds!Test3.Value = "Z" AND Fields!Test4.Value >10, "SemiBold",
          True, Nothing)

SWITCH Evaluates each expression/result pair and stops when it hits the first that evalutes to True. The final 'True, Nothing' acts like an else. SWITCH if easier to read than nested IIFs but IIF can be simpler if the rules are simple.

UPDATE:

The following shows doing this using HTML generated in the dataset query. I know next to nothing about HTML this this may be fixable but here's where I got to ....

Based on your sample table I created a new column with a HTML version of the address using </p> to create the line breaks.

It also suppresses blank rows.

The sql looks something like

SELECT 
    HomeAddrFormattedP1 = '<p>Home Address: </p>' 
                        + IIF( ISNULL(h_street1,'')='', '', IIF( LEFT(h_street1,1) = 'x', '<b>' + h_street1 + '</b></p>', h_street1 + '</p>') )
                        + IIF( ISNULL(h_street2,'')='', '', IIF( LEFT(h_street2,1) = 'x', '<b>' + h_street2 + '</b></p>', h_street2 + '</p>') )
                        + IIF( ISNULL(h_street3,'')='', '', IIF( LEFT(h_street3,1) = 'x', '<b>' + h_street3 + '</b></p>', h_street3 + '</p>') )
                        + IIF( ISNULL(h_foreign_cityzip,'')='', '', IIF( LEFT(h_foreign_cityzip,1) = 'x', '<b>' + h_foreign_cityzip + '</b></p>', h_foreign_cityzip + '</p>') )
                        + IIF( ISNULL(h_city,'')='', '', IIF( LEFT(h_city,1) = 'x', '<b>' + h_city + '</b></p>', h_city + '</p>') )
                        + IIF( ISNULL(h_state_code,'')='', '', IIF( LEFT(h_state_code,1) = 'x', '<b>' + h_state_code + '</b></p>', h_state_code + '</p>') )
                        + IIF( ISNULL(h_zipcode,'')='', '', IIF( LEFT(h_zipcode,1) = 'x', '<b>' + h_zipcode + '</b></p>', h_zipcode + '</p>') )
                        + IIF( ISNULL(h_country_code,'')='', '', IIF( LEFT(h_country_code,1) = 'x', '<b>' + h_country_code + '</b></p>', h_country_code + '</p>') )                        
    , 
    *
FROM myTable

Using this as my report's dataset query I then added a simple table with 3 columns one for HomeAddrFormattedP1, first_name and last_name

All I did then was right-click the HomeAddrFormattedP1 placeholder and set its properties to Markup Type = HTML

This gave the following final result.

enter image description here

Alan Schofield
  • 19,839
  • 3
  • 22
  • 35
  • Thanks for the reply. I think you're right and SWITCH is the way forward but it's adding "Bold" to the rest of the expression values even though I'm specifying only the first two values in the expression. I'm setting this in FontWeight within the Placeholder Properties of the expression. – DHorse1984 Apr 21 '20 at 15:36
  • you can apply the same expression just in the place holder properties and leave the textbox properties alone. it should work in the same way. If this is not working, update the question with a screen shot of the issue and any relevant expressions – Alan Schofield Apr 21 '20 at 15:41
  • Thanks again Alan. Still getting bold on all expression values though. I've updated the question. – DHorse1984 Apr 21 '20 at 18:53
  • I'm assuming that you were expecting to see everything before the first colon as normal weight? Are there any format expressions in the textbox itself? I just created a simple sample and it worked as expected. If you have no formatting at the textbox level, can you add another column into the report, stick two placeholders (anything will do, even static text) in and format 1 of them to see what happens. I can't see anything wrong with what you have posted but there maybe something that I can't see that is causing this. – Alan Schofield Apr 21 '20 at 20:57
  • Thanks Alan. It works when I split the values/placeholder out in a new textbox like you suggested, no problem. When I use the expression I created in a new row/textbox the "bold" duplicates again. It might have something to do with the concatenation of values in the expression. To use this with my current expression I think I'll need some report custom code to identify the "x" in the string and bold the value accordingly. – DHorse1984 Apr 21 '20 at 22:34
  • I'd probably have to have the full RDL and some sample data to do any more, sorry I couldn't help more. – Alan Schofield Apr 22 '20 at 08:33
  • Actually, I may have misunderstood the issue. I thought the issue was the whole TEXTBOX was being bolded but are you saying the the whole PLACEHOLDER is? If it's the latter then this is correct, you've set the format on the placeholder and you can only do that once. The other options would be to programatically add simple html tags or have separate placeholders. – Alan Schofield Apr 22 '20 at 08:44
  • As the values are concatenated creating one long string within the expression would there be a way of targetting the values via SUBSTRING? – DHorse1984 Apr 22 '20 at 13:34
  • you would have to embed html tags, edit the question to show sample data as it comes out of the dataset query and I'll take a look if I get time – Alan Schofield Apr 22 '20 at 13:59
  • Thanks again Alan. I've added some sample data from the query. Thanks for your help, I really appreciate it! – DHorse1984 Apr 24 '20 at 02:30