views:

95

answers:

1

Hello, can anyone help please. I need to put an IIf within an IIf within an IIf. I have a parameter called 'Period' with 4 labels, '24 Hrs, 3 Days, 7 Days, Month'. I have another Parameter ('Date' and hidden) containing the following DateSerial

'=DateSerial( Datepart("YYYY",Now()),Datepart("m",Now()),Datepart("d",Now())-1 )'

which the parameter Period defaults to on opening e.g. 20/10/2009 07:00

The third Parameter ('Date From' also hidden) is where I want to put the nested IIfs. I want it to read from the Parameter 'Period' and depending on the selection will depend on outcome, my code so far looks like this (not completed yet as I want to see if the first two IIfs work:

'IIf(Parameters!Period.Value = 1, DateAdd("h", 7, Parameters!Date.Value),
 IIf(Parameters!Period.Value = 2, DateAdd("h", -41, Parameters!Date.Value)))

Can anyone tell me where I am going wrong.

Regards, Althea

A: 

You need a "else" value in the second IIf just in case your Period is neither 1 nor 2:

=IIf(Parameters!Period.Value = 1, 
    DateAdd("h", 7, Parameters!Date.Value),  
    IIf(Parameters!Period.Value = 2,
        DateAdd("h", -41, Parameters!Date.Value),
        Parameters!Date.Value)) ' If period is neither 1 nor 2 just return the date
Anthony Conyers

related questions