Solved

SSRS Grouping Problem

Posted on 2015-02-16
4
26 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
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
What is the problem that you are having with grouping?
0
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

How to use Variables  and Custom code in SSRS report and Assembly reference to use compile shared code in SSRS. Its big question for all who are working with SSRS. It is easy to create assembly and refer in SSRS report, still there are some steps…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now