Solved

SSRS ISNULL -  errors in report

Posted on 2009-06-30
7
1,376 Views
Last Modified: 2012-05-07
I have been using Access for years now, but am switching over to SSRS and have had a couple hiccups along the way. I have been rewriting old access reprts in reporting services, and have gotten the following errors:

 Msg 174, Level 15, State 1, Line 13
The isnull function requires 2 argument(s).

Msg 174, Level 15, State 1, Line 26
The isnull function requires 2 argument(s).

I have used isnull for a long time, and i can't see where i'm going wrong here. Thanks for any help or sugestions.
SELECT 
		PART.PRODUCT_CODE, 
		PART.USER_8, 
		SHIPPER.PACKLIST_ID, 
		CUSTOMER_ORDER.CUSTOMER_ID, 
		SHIPPER_LINE.CUST_ORDER_ID, 
		CUST_ORDER_LINE.ORDER_QTY, 
		SHIPPER_LINE.USER_SHIPPED_QTY, 
		CUSTOMER_ORDER.ORDER_DATE, 
		CUST_ORDER_LINE.LINE_NO, 
		CUST_ORDER_LINE.PART_ID, 
		PART.DESCRIPTION, 
		IIf(IsNull([CUST_ORDER_LINE.DESIRED_SHIP_DATE]),
			[customer_order.Desired_Ship_Date],
			[CUST_ORDER_LINE.DESIRED_SHIP_DATE]) 
							AS DesiredShip, 
		CUSTOMER_ORDER.DESIRED_SHIP_DATE, 
		CUSTOMER_ORDER.PROMISE_DATE, 
		DateDiff(day,[CUSTOMER_ORDER.ORDER_DATE],
			[SHIPPER.SHIPPED_DATE]) 
							AS ActualLeadTime, 
		SHIPPER.SHIPPED_DATE, 
		DateDiff(day,[Desiredship],
			[SHIPPER.SHIPPED_DATE]) 
							AS LateDelivery, 
		DateDiff("d",IIf(IsNull([CUST_ORDER_LINE.DESIRED_SHIP_DATE]),
			[customer_order.Desired_Ship_Date],
			[CUST_ORDER_LINE.DESIRED_SHIP_DATE]),
			[SHIPPER.SHIPPED_DATE]) 
							AS Late, 
		DateDiff(day,
			[Customer_order.promise_date],
			[SHIPPER.SHIPPED_DATE]) 
							AS LateToCustomer, 
		Abs(DateDiff("d",
			[CUSTOMER_ORDER.PROMISE_DATE],
			[CUSTOMER_ORDER.ORDER_DATE])) 
							AS CustomerLeadTime
FROM (SHIPPER INNER JOIN SHIPPER_LINE ON 
				(SHIPPER.PACKLIST_ID = SHIPPER_LINE.PACKLIST_ID) 
			AND (SHIPPER.CUST_ORDER_ID = SHIPPER_LINE.CUST_ORDER_ID)) 
	 INNER JOIN (CUSTOMER_ORDER 
	 INNER JOIN (CUST_ORDER_LINE 
	 INNER JOIN PART 
		ON CUST_ORDER_LINE.PART_ID = PART.ID) 
		ON CUSTOMER_ORDER.ID = CUST_ORDER_LINE.CUST_ORDER_ID) 
		ON (SHIPPER_LINE.CUST_ORDER_ID = CUST_ORDER_LINE.CUST_ORDER_ID) 
		    AND (SHIPPER_LINE.CUST_ORDER_LINE_NO = CUST_ORDER_LINE.LINE_NO)
 
 
WHERE (((SHIPPER_LINE.USER_SHIPPED_QTY)>0) 
 
		AND ((SHIPPER.SHIPPED_DATE) 
		Between '4/1/2009' And '4/30/2009'));

Open in new window

0
Comment
Question by:Hoyt81
[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
7 Comments
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 24748657
ISNULL function in SQL Server requires two arguments, and hence it should be

isnull([CUST_ORDER_LINE.DESIRED_SHIP_DATE], [customer_order.Desired_Ship_Date])

instead of

IIf(IsNull([CUST_ORDER_LINE.DESIRED_SHIP_DATE]),
                        [customer_order.Desired_Ship_Date],
                        [CUST_ORDER_LINE.DESIRED_SHIP_DATE])

Hope this helps.

Replace the another similar construct too.
0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 24748669
And hence you can remove your IIF statement too.

Hope this helps
0
 

Author Comment

by:Hoyt81
ID: 24748909
This does help a lot. The report is now functioning, but the data i'm going for is not exactly correct, close though.

I was able to get these "isnull" expressions to work in access, but i will have to find another way to get them working properly here.

As you can see, my 2nd error has 4 arguements that together in access delivered the 'Late' column. You wouldn't happen to have any suggestions on how perform the equivilent in SSRS? Apologies for the seemingly novice question, i'm still stumbling through this!
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 8

Expert Comment

by:Hadush
ID: 24749587
You can change it to case statment if you like to like
 


Case when CUST_ORDER_LINE.DESIRED_SHIP_DATE is null then [customer_order.Desired_Ship_Date] 
else [CUST_ORDER_LINE.DESIRED_SHIP_DATE]) end AS DesiredShip 

Open in new window

0
 
LVL 15

Accepted Solution

by:
rob_farley earned 500 total points
ID: 24770630
The problem comes down to the fact that you're mixing T-SQL (SQL Server's query language) with VB (SSRS's expression language).

IIF and ISNULL(Value) are VB constructs (and ISNULL evaluates to true/false)
ISNULL(Value, OtherValue) is a T-SQL construct which evaluates to either Value or OtherValue.

The T-SQL equivalent of IIF is CASE, as is shown above.

You can use your VB skills in SSRS if you want by adding a calculated field to your dataset. To do this, right-click on the dataset and choose the option to add new field. This won't affect what is returned from the database - it just lets you have a new field available to your report.

Alternatively, you can edit the T-SQL query, and pull that new field back from the database (but then you have to use the CASE construct).

If you need to the Desired_Ship_Date fields in your report (as well as the new DesiredShip field), then I'd use a Calculated Field in SSRS. If you just need DesiredShip, then I'd use the T-SQL construct that Hadush wrote above within your query.

I hope this helps explain things for you...

Rob
0
 
LVL 9

Expert Comment

by:Tone' Shelby
ID: 24775035
Another way in TSQL is to use the ISNULL() Function and bring in a default value for all nulls without having to use a CASE is ...
ISNULL ( check_expression , replacement_value )
example:
USE AdventureWorks;
GO
SELECT Description, DiscountPct, MinQty, ISNULL(MaxQty, 0.00) AS 'Max Quantity'
FROM Sales.SpecialOffer;
GO
For more info refer to: http://msdn.microsoft.com/en-us/library/ms184325.aspx
0
 

Author Closing Comment

by:Hoyt81
ID: 31598488
Thanks for the explanation.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

756 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