+ Reply to Thread
Results 1 to 8 of 8

Thread: Sum and iifs

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

    Sum and iifs

    Hi,

    I need to compare a field to see if it matches the invalid code then sum the fields that don't match. I am using the code below in SSRS to try and accomplish this but it is adding all the fields and not pulling only the NV's.

    =sum(iif(Fields!PROCESSING_STATUS_CODE.Value <>"%NV%",cdbl(Fields!RCVDPKG_TO_MSSNGNFO_DAYS.Valu e),cdbl(0)))

    I hope someone has a good idea on how to fix this issue.

    Thanks,
    Kristi

  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

    So the value you have stored in the database for Processing_Status_Code is exactly %NV%, right?

    I tend to like doing these messier things in the query rather than the report. Considering adding the following to the Select statement in the dataset for your report (if it makes sense):
    Code:
    SELECT .....
         , Sum(Case Processing_Status_Code When "%NV%" Then 0 Else Rcvdpkg_to_mssngino) as RcvdpkgTotal
    
    [edit]
    That would only make sense if this is a detail line rather than a footer line -- now that I'm thinking about it, I bet you are trying to aggregate a column in your report into a footer, right?
    Last edited by Wolffy; October 20th, 2009 at 05:01 PM.
    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

    I would love to do it in the code but unfortunately I have developers who build the queries then I have to figure out how to make them work with SSRS. lol I dont know why they like to terrorize me that way.

    I am not trying to put it in the footer but it is the only thing that the report needs to show.

  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

    I'm confused. I'm talking about the datasets in the Report (*.rdl); that which you find under the data tab in SRSS. Are you saying that some other person writes these queires?

    How is the field PROCESSING_STATUS_CODE defined in the sql table? And are you double dog sure it returns %NV% for an invalid value -- that just seems kinda weird.
    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

    You caught me trying to google my way out this mess before posting =) I found something that looked like it would work. I am just learning all this stuff. =)

    It is a text field and it is a variety of codes that start with NV if it isn't valid and a few codes that identify it as valid. I was trying to pull everything that didn't start NV and add those together to get my total.

    I am working off a stored procedure built by someone else in SSRS.

    Thank you for being so helpful and patient with my SSRS newbiness.

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

    Got it work:
    =Sum(iif(InStr(Fields!PROCESSING_STATUS_CODE.Value ,"NV")=0,cdbl(Fields!RCVDPKG_TO_MSSNGNFO_DAYS.Valu e),cdbl(0)))


    Thank you for helping me.

  7. #7
    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

    Ah, OK. You are trying then to emulate the SQL WHEN...LIKE syntax in SSRS. If all the invalid codes start with NV, then use left(Fields!PROCESSING_STATUS_CODE.Value, 2) = "NV"

    And we specialize in newbiness here
    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.

  8. #8
    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

    Quote Originally Posted by kristilee View Post
    Got it work:
    =Sum(iif(InStr(Fields!PROCESSING_STATUS_CODE.Value ,"NV")=0,cdbl(Fields!RCVDPKG_TO_MSSNGNFO_DAYS.Valu e),cdbl(0)))
    Yup, that will work too. It's a little dangerous in that it will match NV anywhere in the value, so if you have a status of invegas it will be considered invalid.
    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

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