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

Boggled with inflated Counts in Dataset SSRS 2008R2 Expand / Collapse
Author
Message
Posted Tuesday, July 9, 2013 10:57 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 11:49 AM
Points: 28, Visits: 142
I'm actually using Visual Studio 2008 to create this report. I have a report already setup that has been working beautifully until someone asked to limit the FY to date numbers according to the selected Trans Month at run time. For example, the dataset will pull through June 2013, but they want to limit the data to April 2013 if that's the month they've selected.

This particular report is using the Matrix to divide the data points into 4 different "quadrants" for current month, prior year month, FYTD vs PFYTD, and Rolling 12 months data.
So, I added MonthDate to the query for the FYTD dataset, and everything that is summed comes out correctly - still on just ONE line; however, the columns that are counting customers, products, etc. now seem to be duplicating the counts by the number of months - although it's not an exact duplication. I've tried changing the aggregate to min, max, avg - nothing changes. The other weird thing is that the query when run within the design of the report or in SSMS works correctly and I get one line with the correct counts. But when it's a run time that my count data points are off.

Hopefully, someone knows an answer or tip -here's the query that may or may not help. This query is essentially the same for all datasets - only this one is running against a FYTD data table:
--DECLARE @TransDate date = '6/1/2013'
--DECLARE @CompanyID nvarchar(4) = '003'
--DECLARE @BU nvarchar(20) = 'BROADLINE'
--DECLARE @PC nvarchar(20) = 'ALL'
--DECLARE @Family nvarchar(40) = '06 Fzn Groceries And Other'
--DECLARE @ProdLine nvarchar(40) = '59 Fzn Breads & Doughs'
--DECLARE @ProdGrp nvarchar(40) = 'ALL'
--DECLARE @PriVend nvarchar(60) = 'ALL'
--DECLARE @Label nvarchar(10) = 'ALL'
--DECLARE @Sodexo nvarchar(20) = 'ALL'
--DECLARE @Schools nvarchar(20) = 'ALL'

SELECT
MonthDate
,CustCount
,PriVendCount
,LabelCount
,ProdCount
,TruCost
,AvgCost
,Billbacks
,OIDisc
,NetSales
,InvQty
,CWT
,PoundsSold
,CBU
,VendAllow
,TotalGPDollars
,Outs
,Shorts

FROM
( SELECT
max(MonthDate) as Monthdate
,COUNT(DISTINCT isnull(PriVendID,0)) as PriVendCount
,COUNT(DISTINCT isnull(Label,0)) as LabelCount
,COUNT(DISTINCT isnull(ProdNbr,0)) as ProdCount

,COUNT(DISTINCT isnull(CustNbr,0)) as CustCount
,SUM (ISNULL (TruCost,0)) as TruCost
,SUM (ISNULL (AvgCost,0)) as AvgCost
,SUM (ISNULL (Billbacks, 0)) as Billbacks
,SUM (ISNULL (OIDisc, 0)) as OIDisc
,SUM (ISNULL (NetSales, 0)) as NetSales
,SUM (ISNULL (InvQty,0)) as InvQty
,SUM (ISNULL (CWT,0)) as CWT
,SUM (ISNULL (PoundsSold,0)) as PoundsSold
,SUM (ISNULL (CBU,0)) as CBU
,SUM (ISNULL (VendAllow, 0)) as VendAllow
,SUM (ISNULL (TotalGPDollars, 0)) as TotalGPDollars

,SUM (ISNULL (Outs,0)) as Outs
,SUM (ISNULL (Shorts,0)) as Shorts

FROM dbo.EES_FYTD

WHERE
--MonthDate = @TransDate
(MonthDate >= dateadd(month, datediff(month, 0, @TransDate) - (12 + datepart(month, @TransDate) - 10) % 12, 0)) AND MonthDate < dateadd(ms,-3,DATEADD(mm, DATEDIFF(month,0, @TransDate)+1, 0))
AND Branch IN (@CompanyID)
-- OR 'ALL' IN (@CompanyID) )
AND (BusinessUnit IN (@BU) OR 'ALL' IN (@BU))
AND (PCNbr IN (@PC) OR 'ALL' IN (@PC))
AND (ProdFamily IN (@Family) or 'ALL' IN (@Family))
AND (ProdLine IN (@ProdLine) OR 'ALL' IN (@ProdLine))
AND (ProdGroup IN (@ProdGrp) OR 'ALL' IN (@ProdGrp))
AND (Label IN (@Label) OR 'ALL' IN (@Label))
AND (PriVendName IN (@PriVend) OR 'ALL' IN (@PriVend))
AND (Sodexo IN (@Sodexo) OR 'ALL' IN (@Sodexo))
AND (Schools IN (@Schools) OR 'ALL' IN (@Schools))
--GROUP BY
-- MonthDate


) as CustVendProdGrpSales
--WHERE
-- MonthDate = @TransDate

OPTION (RECOMPILE)

Thanks in advance!! = )
Post #1471755
Posted Tuesday, July 9, 2013 2:10 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 11:49 AM
Points: 28, Visits: 142
I kept trying different solutions and I kept getting the same results for the counts. Finally determined it was because I had to upload and replace the revised report on the user interface. I thought using Deploy in Visual Studio was the last step.
Post #1471842
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse