0
votes

I hope someone can assist or point me in the right direction

I have a report that contains Fields!District.Value, If this value = "area 1" then i would like to add 60 days to the Field!Date.Value

Obligatory "I'm still learning" SSRS and I have tried the following with no success;

=IIf(Fields!District.Value="North Lanarkshire","DateAdd("d", 60, Fields!Date.Value)"

I'm assuming it's placement of a , or )

thanks in advance for your help :)

1

1 Answers

0
votes

There are a couple of mistake here. Let's break it down.

To start with the IIF function syntax can be thought of like this..

IIF([Expression to evaluate to true or false], [expression to return if true], [expression to return if false])

So your first expression Fields!District.Value="North Lanarkshire" is fine, this will return true or false.

Next expression, what to return if true is close but not correct. "DateAdd("d", 60, Fields!Date.Value)". There is no need for the outer quotes and instead of "d" you should use DateInterval.Day so this should end up being DateAdd(DateInterval.Day, 60, Fields!Date.Value).

Finally we need something to return if the result is false (i.e. District is not "North Lanarkshire"). I'll assume you just want the original date column's value returned here so we can just use Fields!Date.Value

So, the final expression should look like this.

=IIF(Fields!District.Value="North Lanarkshire", DateAdd(DateInterval.Day, 60, Fields!Date.Value), Fields!Date.Value)