SSRS Parameter Question

,

We have a report that displays the following info:

Originally this report was made by a consultant and I was tasked with making this report run off of a date range (the consultant didn’t have any date info in here).

So I added the parameters and what not, and I can get it to actually run off of the StartDate and EndDate I put in there… But any PY or YTD field has “GETDATE” (today’s date) for comparisons. I would like to change those all to the StartDate/EndDate values - so that the PY Current Month will actually run off of StartDate, instead of today’s date…

Here’s a sample of the dataset:

 (
SELECT 
PART.ProdCode as ProdGrpCode,
CUSTOMER.GroupCode as CustGrpCode,
PART.PARTNUM AS PART_NUMBER, 
CUSTOMER.NAME AS CUSTOMER_NAME,
SALESREP.SALESREPCODE AS  SALES_REP, 
round(SUM( CASE WHEN MONTH(ORDERHED.ORDERDATE) = MONTH(GETDATE()) AND YEAR(ORDERHED.ORDERDATE) = YEAR(GETDATE()) THEN   [OrderHed].[OrderAmt] / NULLIF(OrderHed.TotalLines, 0) ELSE 0 END),2) AS CURRENT_MONTH_ORDER_AMOUNT

As you can see it’s grabbing the CURRENT_MONTH_ORDER_AMOUNT via the GETDATE function.

How can I change that to the StartDate/EndDate? I tried changing it to -

MONTH(@StartDate()) AND YEAR(ORDERHED.ORDERDATE) = YEAR(@StartDate()) THEN   [OrderHed].[OrderAmt] / NULLIF(OrderHed.TotalLines, 0) ELSE 0 END),2) AS CURRENT_MONTH_ORDER_AMOUNT

But it doesn’t like that at all. Same with parenthesis around “@StartDate”…

Here’s an example of the errors I get -
image or image

Anyone? Is this possible or no?

@StartDate() shouldnt be like that, it should be (@StartDate). Try using this:
round(SUM( CASE WHEN MONTH(ORDERHED.ORDERDATE) = MONTH((@StartDate)) AND YEAR(ORDERHED.ORDERDATE) = YEAR((@StartDate)) THEN [OrderHed].[OrderAmt] / NULLIF(OrderHed.TotalLines, 0) ELSE 0 END),2) AS CURRENT_MONTH_ORDER_AMOUNT

and verify that StartDate and EndDate are defined as date/time parameters on ReportProperties

1 Like

It doesn’t even need (). It could be
round(SUM( CASE WHEN MONTH(ORDERHED.ORDERDATE) = MONTH(@StartDate) ect…

1 Like

Thanks Dan and Fernando… Yet another simple fix!