+ Reply to Thread
Results 1 to 6 of 6

Thread: Counting a field of two columns if the values don't match in SSRS

  1. #1
    Barn Newbie kristilee is an unknown quantity at this point kristilee's Avatar
    Join Date
    Sep 2009
    Posts
    9
    Rep Power
    3

    Counting a field of two columns if the values don't match in SSRS

    Hi,

    I am using SSRS to develop a report to put out on Report Manager. I have a stored procedure that produces two columns that I need to compare in SSRS and count only if the auditlater value is No and the auditnow is Yes. I cant seem to get the =Count(iif(Fields!auditnow.Value = Fields!auditlater.Value, 1, Nothing), "DataSetName") to not count all the occurences. I am new to SSRS and not sure how to make this work for me. Any help would be appreciated.

  2. #2
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    Why not make it easier on yourself and return a third column as in
    Code:
    case
      when auditLater = 'no' and auditnow = 'yes' then 1
      else 0
    end as countingField
    
    and then in the Report, just
    Code:
    =Sum(Fields!countingField.Value)
    
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  3. #3
    Barn Newbie kristilee is an unknown quantity at this point kristilee's Avatar
    Join Date
    Sep 2009
    Posts
    9
    Rep Power
    3

    Thank you for your reply. Unfortunately I didn't create the stored procedure and it is like pulling teeth to get someone to help with that. Is this the only option?

  4. #4
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    Nope, not at all. I just like to let the server do all the hard work. The same idea can be done in SSRS. Try something like the following:
    Code:
    =Sum(iif((Fields!auditNow.Value ='yes' and Fields!auditLater.Value = 'no'), 1, 0)
    
    Last edited by Wolffy; September 4th, 2009 at 10:59 AM. Reason: Forgot the .Value
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  5. #5
    Barn Newbie kristilee is an unknown quantity at this point kristilee's Avatar
    Join Date
    Sep 2009
    Posts
    9
    Rep Power
    3

    Thanks again for your reply--I will keep fiddling with it. It seems to accept it but is now telling me I have the incorrect # of parameters for Sum.

  6. #6
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    Yeah, looks like a messed up the parens a bit. Not that swift with off-the-cuff SSRS functions.
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

+ Reply to Thread

Similar Threads

  1. Fuzzy Match without SSIS
    By Wolffy in forum SQL Development
    Replies: 1
    Last Post: June 29th, 2009, 11:28 PM
  2. Backup SSRS Server
    By harish in forum SQL Server Reporting Services Help
    Replies: 4
    Last Post: May 6th, 2009, 06:58 AM
  3. Export to Excel SSRS 2000 Unreadable Content Error
    By Lauramc in forum SQL Server Reporting Services Help
    Replies: 1
    Last Post: April 24th, 2009, 09:02 AM
  4. Use of COALESCE to evaluate multiple columns
    By Lauramc in forum SQL Development
    Replies: 1
    Last Post: April 21st, 2009, 08:24 PM
  5. Replies: 3
    Last Post: April 12th, 2009, 11:59 PM

Bookmarks

Posting Permissions

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

SEO by vBSEO