Solved

SSRS Grouping Problem

Posted on 2015-02-16
4
30 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
ID: 40614787
What is the problem that you are having with grouping?
0
 
LVL 65

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

Suggested Solutions

Title # Comments Views Activity
Present Absent from working date rage 11 48
SSRS 2016 Rendering HTML tables 3 56
IEnumerable<T> to a List<T> 8 51
Removing Headers from report before exporting to Excel 13 19
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Hi All, I am here to write a simple article to move SSRS (SQL Server Reporting Services) reports from one server to another. When I have faced the same issue to move reports those were developed by developer on development server and now need to …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

735 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