Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Sum Expand / Collapse
Author
Message
Posted Thursday, March 13, 2014 3:06 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: 2 days ago @ 2:50 PM
Points: 233, Visits: 706
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?
Post #1550930
Posted Thursday, March 13, 2014 4:19 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 5:39 PM
Points: 184, Visits: 8,393
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
Post #1550952
Posted Thursday, March 13, 2014 9:17 PM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 9:05 PM
Points: 3,044, Visits: 2,649
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.



Post #1551001
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse