I have a field in the report which depends on 3 more fields in the DataSet. The 3 fields are APAC, EMEA and LATAM (Regions). Now There is a Yes and a No in those fields for corresponding Projects. I have to collect the fields with a Yes from each project and display all those regions as Impacted regions in a single field.. Is there a way to do it in SSRS. When I'm using iif I'm only able to display only one region.. supposed if 2 fields have yes, I'm not able to display both..
Iif in SSRS with multiple values
iifreporting-services
Related Solutions
(I'm assuming that you're only getting #ERROR for your null-valued records, since that's what happened when I set up a test case using the expression you provided. If not, I'll investigate further.)
You certainly can use a regex inside of the IIF()
statement, but it evaluates both result conditions regardless of the result of your test expression. Therefore, your Regex.replace()
is performed on your NULL
values as well, which naturally generates an error.
I was able to produce the behaviour I think that you're after by rearranging things a little, so that we have this expression instead (formatted for readability):
=System.Text.RegularExpressions.Regex.Replace(
IIf(IsNothing(Fields!Phone.Value), "", Fields!Phone.Value),
"(\d{3})[ -.](\d{3})[ -.](\d{4})",
"($1) $2-$3")
That will give you a blank field when the value is NULL
, otherwise it will format your telephone numbers accordingly. Hopefully that helps.
Yes, it definitely matters if the field is a Date Time field. If it's a string, then you need to convert it to datetime first. How you do that will depend on the format of the string. But it will be much better if you can stick with a datetime field from the database. (I've seen where some will format a date to a string in the select of the sql query. Don't do that. Format as late as possible: in SSRS, at the text box level.)
If it is a dateTime, break up your formula to find out what's not working as expected and make it more visible, if only for debugging. Put this in the expression of a cell, for example:
=IIF( Fields!Decision_Must_Be_Made.Value <=today(), "Old", "New")
Edited to add information on where the color formula should be added:
Sounds like you don't have the IIF specifying the color in the right place. There are a few different places you could specify this: it needs to be in the properties of either the textbox or the placeholder. The value for these things should simply be your date field (=Fields.Decision_Must_Be_Made.Value
) but the font color needs to be specified separately. One place to do this is in the Text Box Properties dialog. In the font pane, you need to specify the font color. The Fx symbol indicates that you can specify a formula. Click this button for a place to enter your '=iif...' formula.
Best Answer
What about concatenating the results?