Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Sum


Author
Message
sharonsql2013
sharonsql2013
SSC-Addicted
SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)

Group: General Forum Members
Points: 406 Visits: 1220
I am trying to Display the 3 values

=SUM(IIF(Fields!Employee.Value = "FullTime",1,0),"Production") --- This will give the sum of Fulltime employees
= SUM(IIF(Fields!Employee.Value = "Partime",1,0),"Production")---- This will give the sum of Part Time employees
= Count(Fields!Employee.Value,"Production")--- This will give a count of all employees

This returns correct result if there is a value coming in. But there are parameters passed where the Qyery returns no records , That means the Fields!.Employee value doesn't return any thing and the count of the row is zero. I can execute the query in SMS and see that no rows are displayed. I want to display "0" if there are no rows coming in but instead the entire tablix disappears.

Can anyone advise what changes should I make to the expression?
doug.brown
doug.brown
SSC Veteran
SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)

Group: General Forum Members
Points: 268 Visits: 12427
Would something like this work?


=IIF(Fields!Employee.Value Is Nothing, "0", SUM(IIF(Fields!Employee.Value = "FullTime",1,0),"Production") ) --- This will give the sum of Fulltime employees
=IIF(Fields!Employee.Value Is Nothing, "0", SUM(IIF(Fields!Employee.Value = "Partime",1,0),"Production") )---- This will give the sum of Part Time employees
=IIF(Fields!Employee.Value Is Nothing, "0", Count(Fields!Employee.Value,"Production") )--- This will give a count of all employees

happycat59
happycat59
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3565 Visits: 3107
doug.brown (3/13/2014)
Would something like this work?


=IIF(Fields!Employee.Value Is Nothing, "0", SUM(IIF(Fields!Employee.Value = "FullTime",1,0),"Production") ) --- This will give the sum of Fulltime employees
=IIF(Fields!Employee.Value Is Nothing, "0", SUM(IIF(Fields!Employee.Value = "Partime",1,0),"Production") )---- This will give the sum of Part Time employees
=IIF(Fields!Employee.Value Is Nothing, "0", Count(Fields!Employee.Value,"Production") )--- This will give a count of all employees


This won't work because SSRS will not attempt to do anything with the tablix if there are no rows in the associated dataset.

You can configure the "NoRowsMessage" of the tablix but I suspect that this won't do what is needed.

I think that you will need to change the SQL code you are using so that there is at least one record returned. If that record contains values that are not included in the SUM expressions (i.e. the IIF statements return 0), that will work OK. The employee count expression would need to be changed to exclude that record.



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search