Link to home
Start Free TrialLog in
Avatar of Hoyt81
Hoyt81Flag for United States of America

asked on

SSRS ISNULL - errors in report

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

Avatar of Raja Jegan R
Raja Jegan R
Flag of India image

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.
And hence you can remove your IIF statement too.

Hope this helps
Avatar of Hoyt81

ASKER

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!
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

ASKER CERTIFIED SOLUTION
Avatar of Rob Farley
Rob Farley
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of Hoyt81

ASKER

Thanks for the explanation.