Boggled with inflated Counts in Dataset SSRS 2008R2

  • 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!! = )

  • 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.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply