Solved

SSRS Calculation help

Posted on 2016-10-28
6
73 Views
Last Modified: 2016-10-31
Hello. I am new to SSRS and using report writer 3.0. I have created a report that gives me information on our help desk tickets. On the report there is a drop down list called status in which I can select Open, Initiated, or Closed. I have a couple of datasets one called Create, completion date, and days to complete. Once a help ticket is opened "created" is automatically populated with todays date and once a ticket is closed the appropriate date is selected. Then there is an expression done on Days to complete to give me the difference between the two. So for example if I select close from the drop down and select some date parameters and run the report I get:

Created            Completion Date        Days to complete
10/18/2016      10/19/2016                            2
10/18/2016      10/18/2016                            1

This part works correctly. However, In the event the status selected is open or initiated there is obviously no completion date to assign so that field is left blank until closed. So now if I run the report with open or initiated selected in my drop down the expression on Days to complete does not know who to handle the blank value in completion date so I get this as a result.

Created            Completion Date        Days to complete
10/18/2016                                                      -763253
10/24/2016                                                      -736259

In the simplest explanation as possible for a newbie how do a handle the days to complete to not show a value if completion date is blank.

So I would expect something like this.

Created            Completion Date        Days to complete
10/18/2016                                                    
10/24/2016
0
Comment
Question by:DJ P
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 41865205
Are you calculating the days to complete in the report or is it a database value?
If so test for a NULL completed date and set the value to 0

mlmcc
0
 
LVL 16

Accepted Solution

by:
Megan Brooks earned 500 total points
ID: 41865391
It looks like the end date, when not specified, may be treated as zero. The differences you are seeing represent roughly 2000 years in the past. If the value is being delivered to the report as RDL then you can test for it in the textbox expression using something like
=IIf(IsNothing(Fields!completiondatefieldname.Value), "", Fields!daystocomplete.Value)
I don't know what your field names are, so I used the placeholder names "completiondatefieldname" and "daystocomplete". If the non-null value for the textbox is defined by an expression then include the entire expression as the 3rd parameter of the IIf, in place of "Fields!daystocomplete.Value".

(Edited to add missing parenthesis.)
0
 

Author Comment

by:DJ P
ID: 41866964
I cannot get the syntax you provided to work. My fields are as follows:

Created
Completed_Date

DaysToComplete - Has the following expression
=Fields!DaysToComplete.Value

Based on your syntax no matter what I try does not work.
0
Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

 

Author Closing Comment

by:DJ P
ID: 41867266
Sorry, I figured it out. Thanks for the assistance!
0
 
LVL 16

Expert Comment

by:Megan Brooks
ID: 41867277
For those field names the textbox value expression would be
=IIf(IsNothing(Fields!Completed_Date.Value), "", Fields!DaysToComplete.Value)
This expression can be entered directly as the text contained in the textbox. It simply substitutes an empty string for DaysToComplete if Completed_Date is NULL ('Nothing' in VB).

Again, it will only work if the value of Completed_Date coming from the dataset is NULL when the textbox should be blank. If it is being delivered as something else, such as an empty string, then the IIf must test for that instead.

(Note that my original post was missing a parenthesis. I corrected the original, and it is also corrected in this post.)

Here is another version that doesn't use the NULL test:
=IIf(Fields!DaysToComplete.Value < 0, "", Fields!DaysToComplete.Value)

It substitutes an empty string if the DaysToComplete value is less than zero. For this to work, the DaysToComplete field must be an integer (or other numeric value) and not a string.
0
 
LVL 16

Expert Comment

by:Megan Brooks
ID: 41867279
Whoops, we both posted at the same time. I'm glad you got it to work. SSRS is a powerful tool, but not the easiest thing to use!
0

Featured Post

Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by Valentino Vranken. A while ago I wrote an article called Chart Optimization Tips (http://www.experts-exchange.com/articles/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Chart-Optimization-Tips.html).  This article explained how …
Steps to solve SSRS SQL 2008 R2 User Access Control (UAC) Permission Error With the introduction of SQL Server 2008 R2 and Vista (Windows 7 as well) came new enhanced security features. One of the features included was User Access Control (UAC) t…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question