I've a custom Invoice that I'm building and it's divided up into four sections. I have built the data set so that it has the following data:
Code, Earnings, Rate, Cost, Total, Section
My stored procedure attaches a section based on criteria in within.
I placed a table on the report and added the first 4 data elements and then put a row visibility constraint on it based on section <> 1. Then I added three more tables to the report, each instead having the row visibility constraint <> 2,3,4.
All this displays properly.
Now in each table, i want to subtotal only the rows that are visible based on the filter. But when I try to do a sum, I get the "grand total" of all rows(unfiltered).
In the sample picture below you can see the 4 sections and the red circles show where =SUM(Fields!Total.Value) display the "grand total". The values should be:
17,887.55
0
32.48
22.86
Ideas?
Thanks,
PS It won't let me display the image of my report, so i have it here on my Microsoft Exchange OneDrive: http://1drv.ms/1HPXdgO
It seems like you have a row group on “wc code/Description”. You just need to pass scope (name of the row group) in your sum method. So your method will look like:
=SUM(Fields!Total.Value,””)
Here is what I did to solve the problem though it's a work around rather than actually doing what I wanted SSRS to do.
I added four more records to my stored procedure each one grouping by section and forcing a section 101, 102, 103, and 104 to correspond to sections 1, 2, 3, and 4. Then a fifth record is added to correspond to the grand total record and section 1000 is used to denote this.
Then I added 4 more tables(each having only one row) to the report each filtering on 101, 102, 103, and 104 respectively and the grand total table filtering on 1000.
This makes the report function as per my requirements. If anyone knows how to do it in the report designer, please reply and i'll mark as solution.
Related
I'm creating a new report where one of my flags as to do with the Taxes we have here in Quebec. In this report, I'm displaying invoices with a header, the details (items) and then the total with the taxes.
Now here in Quebec we have TPS and TVQ as taxes. Sometimes, when we sell outside of the Quebec area at one of our other branch, we wont have the TVQ.
The goal of my flag, is to turn the textbox red when TPS is there and TVQ isn't there. I also want to do the same thing if TVQ is there and TPS isn't.
I kinda feel like it should look a little like that
IIF ((Fields!TAXDLID.Value = "TPS") AND (Fields!TAXDLID.Value = "TVQ"), black, red)
but I can't wrap my head around.
Thanks for the help!
edit:
Here is something that works and doesn't need red flags
Here is something that also works and doesn't need red flags
Here is something that does not work and would need a flags since it doesn't have TVQ
It's also possible to have nothing in the section
It's not perfectly clear what your dataset looks like (from your dataset query) so I have made some assumptions as follows:
Each row in your dataset has a Column that is either 'TPS' or 'TVQ'
Your dataset only contains data for a single invoice per report.
Your main report dataset is called dsMain
Assuming 1 invoice per report
Assuming the above, as your column can only contain one of two values we can simple count how many unique values are in the dataset.
You can do something like this
=IIF(CountDistinct(Fields!TAXDLID.Value,"dsMain") >1, "Black", "Red")
More than one invoice per report
If you are producing more than one invoice per report then I would imagine you have a row group setup that groups by invoice number. If this row group is called grpInvoice then you need to swap out the dsMain scope expression for the name of your row gorup
e.g.
=IIF(CountDistinct(Fields!TAXDLID.Value,"grpInvoice") >1, "Black", "Red")
Note
The scope name MUST be the exact spelling of the row group name or dataset name, it is case sensitive AND is must be enclosed in quotes as per the example.
If this does not help, please provide a sample of the data that comes from your dataset query and your report design including grouping info where applicable.
Does anyone have any experience of creating a report that will print labels that are on a roll?
I can see plenty of examples for a sheet of labels, but nothing with any great detail regarding a roll.
Would the best method be to set the report page up to have 1 column and then adjust the size of the page to be the size of the label?
There will be different info on each label, and a varying number of labels per print.
So basically set up the report to mirror the label size and then repeat pages depending on how many labels need printing?
You should just be able to set your report to have the same page size as your label then design the report as normal.
As for producing multiple labels, you can either
have a single dataset containing all the info you need for all labels and group by whatever makes each label unique (e.g. a label number). Then add a page break on the row group property to put a break between each, or ..
you could create a subreport that just handles a single label and then have a master report that with a table control with a single 'cell' and the subreport inside that cell. You would then pass the parameters to the subreport from the main dataset. I think you've seen a similar answer I posted about printing sheets of labels, if you follow that then it should get you most of the way there.
Option 1 is probably the simplest method...
Step-by-Step for option 1
In this example I've used the Microsoft sample database WideWorldImporters, just so I could get some names and addresses.
Step 1: Write your query to get your data. In my example I used the following..
SELECT top 10 o.OrderID, c.CustomerName, c.DeliveryAddressLine1, c.DeliveryAddressLine2, cty.CityName, c.DeliveryPostalCode
FROM [Sales].[Orders] o
JOIN Sales.Customers c on o.CustomerID = c.CustomerID
JOIN Application.Cities cty on c.DeliveryCityID = cty.CityID
ORDER BY OrderID
This just gives me the order number, company name and address.
Step 2: Create a new report. I'm using Visual Studio but the process is almost identical in Report Builder if you use that.
Create a new, blank report
Add a datasource and dataset containing your query from step 1
Select the 'body' and set the size property to your label size. I used 100mm, 40mm
Select the 'report' and set the PageSize property to the same values as above and the margins to 0
Step 3: Add a table to contain the data
Add the new table
Delete the header row
Delete the last column (I have a two column label in my example but obviously up to you)
Select the table (tablix) using the grey table handle (top left of the table) and then set the dataset property to the name of the dataset you created earlier
Add enough rows to contain all your data, in my case 6 in total
In the RowGroups panel under the main report design, right-click the details rowgroup and choose Add Group => Parent Group. Select OrderID as the field to group on and click OK
Remove the newly added column and if prompted choose 'remove column only'
Right-Click the (OrderID) Row group and go to Group properties, click Page Break and choose 'between'
Set each row to contain your data until you end up with something like....
Clean up the formatting and that should be it. One label per page and each page set to your label size.
You may need to adjust the layout slightly to adjust for margins etc but this should give you a good start.
I am new to SSRS. I have a report that goes like this
Type Amount
A 500
B 200
A 100
C 400
C 200
I want to convert this to a report like this
Type Total Amount
A 600
B 200
C 600
Basically get distinct Types on the left column and th totals for those types in the right column. Is there a way i can do that easily?
Thanks
Starting with you simple report which just lists the records in your DataSet:
Design:
Results:
Right click on (Details)in the Row Groups section and choose Add Group -> Parent Group:
Choose the field you want to group by (Type in our example) from the Group by: dropdown, choose to add either a group header or footer and click OK:
Your table will now look something like this:
You can delete the second column and the third row - or second row if you chose to add a group footer earlier - entirely (clicking OK when deleting the row and being prompted to delete the associated group), leaving a layout like this:
Now just click the field selector for the empty cell in the table and choose your Amount field:
or right click on the empty cell, choose Expression from the context menu and enter the following expression:
=Sum(Fields!Amount.Value)
either of which should result in the formula being placed into the cell:
Now run your report and you should get the expected result:
There's loads of places online with similar guides and resources which you can also consult:
MSDN Reporting Services Tutorial (Adding Grouping and Totals)
MS TechNet (Calculating Totals and Other Aggregates)
MSDN (Add a Total to a Group or Tablix Data Region)
There are also several other similar questions here on SO which you'll find if you just search for them.
Here is the view of table in ''conception'' view:
Conception view
And here's what it gives:
Executed view
As you can see my Column group entitled [Poste_Histo___Etat_Description_Abrégé] breaks out into 3 categories when I run the report: Comblé, Vacant and Vacant_att
I want to blend Vacant and Vacant att into just 1 category and name it Vacant, so to have only 2 categories when the report is being run.
I tried multiple functions and there was one that got me close, but event then, it only renamed Vacant_att to Vacant and didn't add the 2 columns though:
=IIF(InStr(Fields!Poste_Histo___Etat_Description_Abrégé.Value, "Vacant") Or InStr(Fields!Poste_Histo___Etat_Description_Abrégé.Value, "Vacant_att"), "Vacant", "Comblé")
So my goal is to figure this out and ultimately, portray these same values on a graph in the same manner: that is to have only "Vacant" and "Comblé" as categories.
p.s. If it makes any difference, all the «Expr» are the following formula:
=Sum(IIF(InStr(Fields!Poste.Value, ""+"300") Or InStr(Fields!Poste.Value, ""+"100"), 1, 0))
It's point is to only get the values for that end with 300 or 100.
Thanks a lot to any1 who helps!
I ended up finding my answer myself lol. For any1 having eventually the same problem, here is my approach:
1- In the Query Designer pane of my dataset, I created 2 Calculated members:
One being Comblé including the [Comblé] category and the other being Vacant in which I combined [Vacant] and [Vacant_att].
2- I used the formula mentioned in my question as partly successful and replaced the 1 with the newly created calculated members correspondingly. So:
For Vacant:
=Sum(IIF(InStr(Fields!Poste.Value, ""+"300") Or InStr(Fields!Poste.Value, ""+"100"), Fields!Vacant.Value, 0))
For Comblé:
=Sum(IIF(InStr(Fields!Poste.Value, ""+"300") Or InStr(Fields!Poste.Value, ""+"100"), Fields!Comblé.Value, 0))
3- So this gave me the right numbers BUT (as per the pic attached) as long as I had [Poste_Histo___Etat_Description_Abrégé] as a Parent Group in my Tablix, which was no good since this dimension has 3 categories originaly (Vacant, Vacan att. and Comblé) I ended up with 3 columns who have 2 columns each (my newly created Calculated members - Vacant and Comblé)... so 6 columns
Table 1.0
4- Finally to tackle this issue, I created 2 columns both out of the parent group [Poste_Histo___Etat_Description_Abrégé] : Vacant2 and Comblé2. And I simply copy pasted that same formula in these but only to discover that the values were all 3 times larger (sum of the 3 columns). As a simple way out, I just divided each formula by 3 and . As so:
=(Sum(IIF(InStr(Fields!Poste.Value, ""+"300") Or InStr(Fields!Poste.Value, ""+"100"), Fields!Comblé.Value, 0)))/3
And voilà!
p.s. in Table 1.0, Vacant2 and Comblé2 are a percentage of the ratio of each calculated member over the sum of the two.
I inherited a report where the Grouping and Aggregation is done in the Report. The Dataset is a SQL Server 2008 Query.
This raw Data:
ID Budget Amount Spent Amount
A 1,500 20
A 1,500 20
A 1,500 60
B 2,000 50
B 2,000 75
B 2,000 75
Shows like this on the report:
ID Budget Amount Spent Amount
A 1,500 100
B 2,000 200
I added a calculated field to the Report to get this:
ID Budget Amount Spent Amount Balance
A 1,500 100 1,400
B 2,000 200 1,800
Can I do something in the report to exclude rows that have a balance less than 1,500?
If not, what are my other options?
****************************
. . . the next day . . .
Having tried suggestions to add a Filter Exp. to the Tablix and a Row Visibility Exp. to the row - unsuccessfully - here is what I found:
My actual report has two Row Groups on the row for which I want to limit the rows that show.
I tried the same suggestions made in this thread on another report [with no Row Groups] ... and the Tablix Filter and the Row Visibility both worked fine.
I have to assume that the fact that my 'problem' report has two levels of Grouping is the cause of the Expressions not working.
BUT . . . is there a way to overcome this?
****************************
I just realized [while researching this same issue elsewhere] that the report I am working with does not have a 'Details' row.
What I was thinking of as a Details row is not. There is no Details Row in this report. I have been trying all your suggestions on a row that is not a Details row.
You can reference a textbox field in your report, per the comments in the thread:
=IIF(ReportItems!textbox1.Value <= 1500, True, False)
Throw this expression in the row details visibility section. Or you can even use the filters section to filter this data out. Tons of ways to do this.
Thanks for all your suggestions. They helped me arrive at a solution.
As I said in my [edited] post, my report has no Details Row.
I was adding the expression to the Visibility Property of the Row on the report Tablix which was not a Detail row.
After reading the topic here:
https://dba.stackexchange.com/questions/53727/how-to-hide-rows-in-ssrs-report
I did this:
-> Right-clicked the last/lowest of the Row Groups in the Groups pane,
-> Group Properties,
-> Visibility,
-> Show or hide based on an expression &
-> Entered this expression [does not relate exactly to my example in the post]:
=IIF((Avg(Fields!AMOUNT_1.Value) - Sum(Fields!AMOUNT_2.Value)) >= 0, True, False)
It is now working exactly as needed.
Thanks for all your input!