IS NULL Parameter

  • How do I do something like this in SSRS 2008?

    If ParameterA is NULL then Getdate() else ParameterA

  • You should be able to do that pretty easily in the underlying query, just by using IsNull or Coalesce.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • =IIF(Parameters!DateLoadedBin.Value=0 OR Parameters!DateLoadedBin.Value Is Nothing,TODAY())

    I am using this but not working.

  • I am trying to do this in my inline query in the where clause

    WHERE

    CASE WHEN (ISNULL(ALLPOINT.DateLoaded),(DATEPART(mm,ALLPOINT.DateLoaded)= DATEPART(mm,GETDATE())

    ELSE DATEPART(mm,ALLPOINT.DateLoaded)= DATEPART(mm,@DateLoadedBin)

    WHERE Am I going wrong ?

    GEtting the following error :

    The isnull function requires 2 argument(s).

  • IsNull doesn't work that way in SQL. You're using it like a binary function (which would make more sense, given the name), but what it really does is return the first of two values which isn't null.

    I'm not quite sure what you're doing in your query, but IsNull works like this:

    select IsNull(null, 1), IsNull (2, 3);

    The first will return 1, the second will return 2. The first non-null value. If both are null, it'll return null.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • PSB (2/17/2011)


    =IIF(Parameters!DateLoadedBin.Value=0 OR Parameters!DateLoadedBin.Value Is Nothing,TODAY())

    I am using this but not working.

    IIF(Parameters!DateLoadedBin.Value=0 OR Parameters!DateLoadedBin.Value Is Nothing,TODAY(), Parameters!DateLoadedBin.Value)

    should work

  • GSquared (2/17/2011)


    IsNull doesn't work that way in SQL. You're using it like a binary function (which would make more sense, given the name), but what it really does is return the first of two values which isn't null.

    I'm not quite sure what you're doing in your query, but IsNull works like this:

    select IsNull(null, 1), IsNull (2, 3);

    The first will return 1, the second will return 2. The first non-null value. If both are null, it'll return null.

    To build on what GSquared said

    ISNULL(ParameterA,GetDate())

    Should return what you want. ISNULL tests the first item for null, if the first item is null, it returns the second item. If the first item is not null, it returns the first item.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply