SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Sum


Author
Message
sharonsql2013
sharonsql2013
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1306 Visits: 1265
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
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1553 Visits: 14922
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
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8845 Visits: 3281
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