SSRS - Cannot figure out the correct grouping

I have this SSRS report, exported to Excel:

Its shows aged invoices and the total balance for each customer. The only grouping i have setup is by customer in order to have a total for each customer.
I have been asked to add all the memos for each customer onto this report. So in the BAQ i had to link the Memo table.

I added the memo description field in within the customer group on the SSRS report. But it comes out like this (memo field in red):

Obviously you can see that i am getting duplicate records. Its supposed to be showing multiple memo lines.

I am assuming that its a grouping issue.
So what am i doing wrong or need to do as far as grouping

The SSRS in designer:

My Query:
image

I would use a sub report for this. Or, add a group for invoice and have the memo as the detail section.

1 Like

Gah, i was hoping I didnt have to do a sub report. I always have such a hard time with sub reports in a SaaS environment.

I’ve done this kind of thing with either a table or list within a group row. You will have to move the invoices into a group to hide the duplicates, and redo your summaries so they don’t include the duplicates. It’s a pain but might be easier than a subreport for you.

So you want it to look like:

ACME INDUSTRIES
Invoice  PrdCode  Code     Inv Num  PONum      ....
=======  =======  ======== =======  ========   ....
  12345  5504     EPD MACH   12345  ABC-DEF    ....
  12350  5504     EPD MACH   12350  ABC-XYZ    ....
  12400  5512     EPD CAST   12400  ZZZ-123    ....
                                    Emailed 60 ....   (this is a memo for one of the invoices)  
                                    Called on  ....   (this is another memo for a differant invoice)  

BALZAR LTD
Invoice  PrdCode  Code     Inv Num  PONum      ....
=======  =======  ======== =======  ========   ....
  12348  5512     EPD CAST   12348  1234567    ....
  12351  5504     EPD MACH   12351  1234569    ....
  12404  5512     EPD CAST   12404  1234575    ....
                                    Spoke with ....   (this is a memo for one of the invoices)  
                                    Called Joe ....   (this is another memo for a differant invoice)  

```

With all the memos, for the invoices for that customer, listed after the section listing the aging?

Close but the memos i need are linked to the customer record, not the invoice.

Ill give this a shot.

What is the source (table.field) of the memo?

Memo.MemoText

Okay. I see that Memos are linked to customers. But how do you filter which memo’s to include? I assume you don’t want to see a memo from 3 years ago. Or maybe you do.

So you want (I’m not going to spend the time to make it pretty)…

ACME IND
Invoice  Prod code ...
12345    512 ...
12350    504 ...
                          Totals .......
ACME IND Memo #1 
ACME IND Memo #2 
ACME IND Memo #3 

that is how i want it to look.
I have it filtered by specific memo categories.

I think you’re going to have to do a sub-report. As there is no convenient relationship between the memos and the invoices.

I would:

  1. Remove the Memo table from the BAQ
  2. Create a new SSRS RDL, with a direct query of the DB, using CustNum as in input parameter. This will be your sub-report.
  3. Insert the sub-report in the “footer” of the customer grouping. By "footer, I mean just below the Detail group, but still inside the Cust group.
1 Like

He’s already got the memos linked to the customer. I don’t believe a subreport is necessary here. Group by customer and invoice. Put invoice information in the invoice group header. In the customer group footer, put a table that is grouped by memo number, with information in the group header. Hide detail rows in both tables. Use OVER() and PARTITION BY in a BAQ calculated field to calculate totals without duplicates.

2 Likes

Very resourceful.

Okay ill give this a go and will post my results. Thanks!

As evidence, here’s something similar I’ve done…this BAQ/report is for determining which midlevel assemblies need to be built so they’re available for top-level assemblies. The single query produces lots of duplicate values.
image

Main table of report is grouped by kanban code and part number. Part info in the part header, and demand and supply tables in the part footer.

Detailed info in the mini-tables is also in group headers.
image

Result is no duplicates.

(Please no judging for the style…it was one of my first reports, and the only one that never gets printed, so I got excited about color. :wink: )

3 Likes

I am not familiar with OVER() and PARTITION BY, how do these work?

Can you show how you used the OVER() Partition By?

There are internet resources that could probably explain HOW these work better than I can, but for our purposes, it means “add up this expression only where these values match”. Your calculated field would be something like “sum(InvcAmt) over(partition by CustNum, MemoNum)”. Instead of adding up that number in the report, just grab it with First(calculated_total), as it’s already been totaled.

This should work because each memo for a given customer should have one copy of each invoice line. The total for one memo will match the total for another memo, provided they have the same customer. Because the sums are split by memo, they don’t get added more than once.

Here’s a quick example of the records you might get by joining tables this way and using partition for your sums. Customer A has two memos, so each invoice gets repeated twice. If you just add those up, you’ll get the wrong total. But if you partition by customer and memo, it will only add the invoices that match the customer and memo, removing duplicates. (Customer B has no memos, so partitioning by customer would yield the correct total on each line.)