Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2002
    Posts
    5

    Question Unanswered: Count in a report

    Hi!

    I have a report and I need to be able to do a count in the Group Footer. I have one count already which counts the number of occurances of a company name and the other one I need should count from a true/false value. The data is grouped by the company name and for each row it has a true/false value, I only want to count the true values, but my count is just counting it whether it is true or false.

    =count([AIPhoned]) -- AIPhoned is type bit, maybe there is some kind of where or countif I could do?

    Please help!

    Thanx
    Dave

  2. #2
    Join Date
    Aug 2002
    Location
    Québec, Canada
    Posts
    109

    counting true/false field

    I suggest you add a field in your select statement, that looks like that:
    Code:
    SELECT ..., IIf([AIPhoned],1,0) AS TrueFalseValue FROM ...
    Then, use that query for the report and use SUM(TrueFalseValue) or whatever the name you use.

    JefB - hope it helps

  3. #3
    Join Date
    Sep 2002
    Posts
    5

    Cool Thanx

    Thanx for your suggestion, I'm sure it works but I kinda met it half way:

    Seeing as AIPhoned is a bit value, it should equal 1 if true and 0 if false. Instead of my original =count I changed it to =sum. For some reason it outputted negative values ie if there were 2 true values it would equal -2, so I just made it =-sum([AIPhoned]). Which seems to work.

    Any problems that I could come accross by doing this?

    Hope this helps others too

    Thanx again
    Dave

  4. #4
    Join Date
    Aug 2002
    Location
    Québec, Canada
    Posts
    109

    true=-1

    A true value is -1 and a false is 0, you could indeed use that, make the sum of AIPhoned, if -10, then there is -10 that are at true, it might be a better way than the one I proposed, but before doing it, make a test with a temp table, you want to be sure it will work well, because I don't know, if your field has garbage, the fact that it is "boolean" will still return true or false, but your Sum might return some oddities!

    JefB

Posting Permissions

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