Solved

SSRS Grouping Problem

Posted on 2015-02-16
4
34 Views
Last Modified: 2015-05-12
Hi,
      I am developing a SSRS Report, which is based on three tables,  Orders , invoice and receipts

the relation between orders and receipts is one to many
the relation between orders and invoice is one to many

and there is no relation between invoice and receipts

I am using left join between these tables to get data.

In my report there are columns related to all 3 tables,


My requirement is date wise filtration of all records , i.e.  if order date is not in between search dates it should not display but if receipts or invoice exists it should be shown.

please find the attachment for sample data and report format. Sample.xlsx
0
Comment
Question by:codeoxygen
[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
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40614787
What is the problem that you are having with grouping?
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 40614894
The attached spreadsheet doesn't make any sense, and the question isn't real clear either, so I'll answer this way..

Most SSRS reports will have as a data source a Stored Procedure, which can accept parameters.

So ... Create a Stored procedure that populates your report, with two parameters for begin date and end date.
Test it to make sure that the return set is 'filtered' based on those dates.

Then in SSRS open the data source, set it to the Stored Procedure, and make sure the parameters are set correctly.
When finished, when a user runs the report, they will be prompted for those two parameters.  When values are entered and the 'Run Report' button is clicked, those values will be fed into the Stored Procedure as parameters, return a set that's filtered by them.
0
 

Author Comment

by:codeoxygen
ID: 40615826
my problem is , when order table is joined with receipts table....

Example : Order is raised on 9th feb , for that respective order receipt is raised on 10th feb and invoice is raised on 11th feb.

In my query i am joining as

Select * from  Order O
left join receipts R on R.orderid=O.orderid
Left join Invoice I on I.orderid=O.orderid


here , if i search with from and to  Date= 9th feb date
only order information need to come

if serch with from date = 9th feb and To Date=10th feb

then  order and its receipt should display, that to in different rows.

if search with from date = 9th feb and To Date=11th feb

then  order ,Invoice and its receipt should display, that to in different rows.


this is the condition but if want get receipts details order details will come automatically in query as it is joined based on order, How to hide those order details if they are not in between search date
0
 
LVL 14

Accepted Solution

by:
nishant joshi earned 500 total points
ID: 40653301
Hello Author,

You can use below code for reference.You need to create one date list which is based on provided data in parameter.

Using that as reference value you can join your order table and it's date to get desire output.

DECLARE 
	@FromDate DATE = GETDATE() - 5,
	@ToDate DATE = GETDATE()

;WITH Dates
AS
(
SELECT @FromDate AS DateList
UNION ALL
SELECT DATEADD(DD,1,Datelist) AS Datelist
FROM Dates
WHERE DateList < @ToDate
)
SELECT *
FROM Dates
INNER JOIN Order O ON o.OrderDate BETWEEN Dates.DateList AND Dates.DateList + 1
left join receipts R on R.orderid=O.orderid
Left join Invoice I on I.orderid=O.orderid

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Written by Valentino Vranken. Introduction: The first step of creating a SQL Server Reporting Services (SSRS) report involves setting up a connection to the data source and programming a dataset to retrieve data from that data source.  The data…
It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

724 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