I'm working on a report and the user picks the claimants from a drop down (this list is always changing) and I want to show each name on it's own line and have the first 2 claimants be bold. this is the expression that I wrote
=switch(Parameters!Claimant.Count = 1, "<b>" + Parameters!Claimant.Value(0) + "</b>"
,Parameters!Claimant.Count= 2,"<b>" + Parameters!Claimant.Value(0) + "</b>" + "<br />" +"<b>" + Parameters!Claimant.Value(1)+ "</b>"
,Parameters!Claimant.Count = 3,"<b>" + Parameters!Claimant.Value(0) + "</b>" + "<br />" +"<b>" + Parameters!Claimant.Value(1)+ "</b>" + "<br />" + Parameters!Claimant.Value(2)
,Parameters!Claimant.Count = 4,"<b>" + Parameters!Claimant.Value(0) + "</b>" + "<br />" +"<b>" + Parameters!Claimant.Value(1)+ "</b>" + "<br />" + Parameters!Claimant.Value(2) + "<br />" + Parameters!Claimant.Value(3)
,TRUE,"Too many people.")
As you can see it checks how many claimants are picked and should run according to what I provided. When I run the report it will run correctly if I select 4 or more claimants. If I pick 3 or less it just show #Error
. Does anyone know what I am doing wrong and how I can fix this?
I think the error is due to the values not existing.
You could use JOIN =JOIN(Parameters!Claimant.Value, "<br>")
but that doesn't work with the bold for the first two.
You can wrap the JOIN in a REPLACE with the bold closing. The REPLACE function will let you specify to replace just once so you can remove the first bold closing tag. There'll be some extra bold close tags, but that shouldn't be a problem.
="<b>" &
REPLACE(
JOIN(Parameters!Claimant.Value, "</b><br>"),
"</b><br>",
"<br>",
, 1
, 1
)
& "</b>"
I added an extra close tag in case there's only one selection.