Results 1 to 19 of 19

Thread: [RESOLVED] [2005] Exclude nulls in Crystal Record Selection Formula

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Resolved [RESOLVED] [2005] Exclude nulls in Crystal Record Selection Formula

    Hi

    Can anyone tell me how I exclude any records with a null value in a certain column when building a Record Selection Formula?

    Thanks.

  2. #2
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    I'm not sure with this but still try:

    [Field] <> Null

    or

    NOT [Field] = Null


  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    I tried "and not (IsNull ({reportView_CompletedAll.Decision}))", this comes up with no errors but doesn't bring back the results I'm expecting!

  4. #4
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    This work fine:
    not isnull({[table].[field]})

    I see that there is an "AND" in your statement, what is the other criteria?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    Year ({reportView_CompletedAll.DateAwarded}) in {?Academic Year} to ({?Academic Year} + 1)
    and
    if Year ({reportView_CompletedAll.DateAwarded}) = {?Academic Year}
    and Month ({reportView_CompletedAll.DateAwarded}) > 8 then True else False
    or
    if Year ({reportView_CompletedAll.DateAwarded}) <> {?Academic Year}
    and Month ({reportView_CompletedAll.DateAwarded}) < 9 then True else False
    and not(IsNull ({reportView_CompletedAll.Decision}))

  6. #6
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    It looks like you are selecting records for an entire year (from Aug, 1 to Aug 31)

    {reportView_CompletedAll.DateAwarded} in DateSerial({?Academic Year}, 8, 1) to DateSerial({?Academic Year} + 1, 9 ,1) And
    Not IsNull ({reportView_CompletedAll.Decision})

    Crystal seems to have problems generating the SQL statement properly when using IsNull. Anyways, try the above and if it still does not work post the Where clause of the SQL Statement that is generated by Crystal (Database -> Show SQL Query menu).

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    It's still bringing back records that have a null value in the {reportView_CompletedAll.Decision} field.

    Here's the SQL it generates:
    SELECT "reportView_CompletedAll"."DateAwarded", "reportView_CompletedAll"."fore", "reportView_CompletedAll"."Sur", "reportView_CompletedAll"."Mode", "reportView_CompletedAll"."RegistrationDate", "reportView_CompletedAll"."Name", "reportView_CompletedAll"."Decision", "reportView_CompletedAll"."CompDate", "reportView_CompletedAll"."ECName"
    FROM "ResearchDB"."dbo"."reportView_CompletedAll" "reportView_CompletedAll"
    ORDER BY "reportView_CompletedAll"."Name", "reportView_CompletedAll"."Mode"

  8. #8
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    In Report Options, are the following Checked or UnChecked.

    Convert Null Field Value to Default
    Use Indexes or Server for Speed

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    The "Convert Database NULL Values to Default" and "Convert Other NULL Values to Default" options were not checked but the "Use Indexes or Server for Speed" was checked.

    I've tried checking and unchecking them in various combinations but it doesn't make any difference.

  10. #10
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    I think the problem is your Formula/Criteria.
    I have no idea what you want to do (I'm not good in reading long post/code coz I don't read it at all ).

    I'll give you a tip.
    Try query it w/ other criteria, put the criteria one-by-one.
    As long as it returns records it is ok, debug it.

  11. #11
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    The Formula I posted is fine, at least it works in Crystal 8.5 against the Northwind.Orders table (SQL Server).

    Does the date portion of the formula work for you?

    What I find curious is that there is no Where clause being generated by Crystal.

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    Yeah, I thought that was weird too!

    The dateserial formula works fine, it's just the part where I want to exclude any records that have NULL in the {reportView_CompletedAll.Decision} field. Even with the Not IsNull ({reportView_CompletedAll.Decision}) line (and variations thereof!) it still brings back these rows!

  13. #13
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    Perhaps the Decision field isn't equal Null but "". To check add the following formula and place it on the report.

    Code:
    If IsNull({reportView_CompletedAll.Decision}) Then
       "Null"
    Else
       If {reportView_CompletedAll.Decision} = "" Then
            "Empty String"
       Else
            {reportView_CompletedAll.Decision}

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    I put a slightly altered version of your code in (it brought up errors without the alteration) but doesn't give any different results, it's like it's not even looking at that field.... the altered version is below:

    If IsNull({reportView_CompletedAll.Decision}) Then
    {reportView_CompletedAll.Decision} = "Null"
    Else
    If {reportView_CompletedAll.Decision} = "" Then
    {reportView_CompletedAll.Decision} = "Empty String"
    Else
    {reportView_CompletedAll.Decision} = {reportView_CompletedAll.Decision}

  15. #15
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    No. I meant create a new Formula. The code I posted does not belong in the Record Selection Formula.

    Print/show this new formula somewhere on the report, preferrably the details section and let me know what gets printed for a row that is null.

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    Ah! I see what you mean! Sorry!

    I created a formula called nullField and put in on the report, the fields that i thought were null were in fact empty strings as you suggested. Then I added the following code to my record selection formula but it made no difference, can you see what I'm doing wrong? Thanks for all your help!

    select {@nullField}
    case "Null": False
    case "EmptyString": False
    default: True

  17. #17
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    The new formula was just to help in debugging the problem. There is no reason to use it in the Record Selection formula.

    Since the Decision field is an empty string the following should work

    {reportView_CompletedAll.DateAwarded} in DateSerial({?Academic Year}, 8, 1) to DateSerial({?Academic Year} + 1, 9 ,1) And
    {reportView_CompletedAll.Decision} <> ""

  18. #18

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    Thanks, I've just tried that now but it makes no difference whatsoever! I looked at the SQL being generated by Crystal and there is still no where clause being included! I'm baffled!

    This is my first time using Crystal, I had no idea it would be so difficult and uninituitive! Give me a programming language anyday!!! Is that your experience of it too?

  19. #19

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Re: [2005] Exclude nulls in Crystal Record Selection Formula

    OK, I surrender! I've changed the way I get the data. I'm now using a view which contains a where clause to exclude the null, I can't see any other way to do it! Thanks so much for your help Brucevde!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width