I have a report that has a group. Lets say the report is grouped by state. And within each state, there are cities.
Attached to each state is some statistic I want to sum up. Lets say it is total number of public schools. This information only exists at the state level and does not exist at the individual city level.
Within each state group, I have detail rows that show bunch of information about each city. That detail isn't relevant for this question so I will skip over that.
Now, here is my question. On this report, I need to show bunch of totals. One of the totals I need to show is total number of public schools.
If I just do a regular SUM, it multiplies out the number attached to each state by the number of cities in each state. What I need to do is take a SUM of public schools and count each state just once.
I hope you understood my question.
Related
I am doing a report with parameters: date(dataInicio, dataFim) and location(unidade). I can select multiple locations.
When I select more than one location it shows me the result of only one location (only one tablix).
What I want it is to show one tablix for each checked location.
The number of rows displayed by the report is controlled by the row grouping in your table. The screenshot doesn't show how many groups you have or what they are grouped on, but you would most likely want a parent row group that is grouped on location. After that, you can have any other level of detail groups as needed. Finally, you would have a details row group (should be there by default) that is not grouped by anything. This allows the report to show all of the details for the location based on whatever the dataset returns.
I got a request from a sales manager. He needs a report that can show the sales volumes per department per customer per reason of purchase for a given period.
Since each department accounts for its sales differently, I developed 12 procedures to get the required data. Some departments need to list the items, and some don't.
All good to this point. So when I put my data into the report, I can't make the 12 tablix go together. E.g., the customer tablix will print all the customer's info, and then the department one tablix will show all the sales and so on.
What I would like to see is a tablix that host the data from the first customer, then the department one tablix, then department two tablix, and so on until all departments are done for the given customer. Then move to the next customer and so on and so.
I can't use the lookup since the customer tablix has no relation to the reason in the other tablix; however, they all relate to the customer code.
I try to copy the tablix one into their customer tablix, hoping to see the break in customers and department one complete data set. But I got an error saying the customer table has no relation to the reasons.
The expectation is to see:
Customer one
Name
Address
Phone
Department one: reason 1, reason 2, reason 3,reason 4
Department two: reason 1, reason 2, reason 3, reason 4
Customer two
Name
Address
Phone
Department one: reason 1, reason 2, reason 3, reason 4```
Ok. In the end, I was unable to make it with the matrix approach. I ended up with a central customer tablix. Then inside the group, I would create a new line for each category, giving them the corresponding label and adding a new sub-report. The subreport would be bound by the customer's I'd to the main tablix. I also had to change all the procedures to use the customer's id; this change allowed me to bound them to the main tablix. Since I already have all the rolling values, I also added a set of independent tablix to summarize the report's beginning.
Not the best solution, but you need to deliver something.
Let's say we have the following data structure in SSRS report:
Disctricts are grouped by city and cities are grouped by country. And then at the country level I'd like to get SUM of population over cities (population is an attribute of a city and districts do not have population associated with them). At the moment, when aggregation is done with =SUM(Fields!city_population.Value) expression, population for each city is taken into account as many times as the number of districts it has associated - that is not correct.
I was thinking of getting data for summation from a supplementary dataset not having division of cities by districts (with the help of LookupSet function). But it probably won't support another grouping level of countries by year which is planned to be done further (can't figure out what can be used as a lookup key in such layout). Is there a way around this situation without lookups?
Update: It needs to be mentioned that City-District is a single entity corresponding to "city district or just the city if it has no districts". This entity was created in data source view as a named query using LEFT JOIN (an approach discussed in this question).
From what I have read I think you are saying that as population is recorded against City, if a City has say 3 districts, then your dataset would return the City 3 times each with the same population.
If this is the case and if the Expression for population is currently SUM(Fields!Population.Value) or similar, try changing it to Max(Fields!Population.Value). It's not a 'pure' solution but I think the results will be what you want and it's a quick fix.
It seems you don't have the right grouping settings in the tablix, a Lookup function is not required in this case.
Add a new tablix component to your report, drag and drop Country field to the Row Groups Pane above details default group.
Right click the Country column and select Insert Column / Inside Group:
In the created column type the header title and use the below expression
=SUM(Fields!city_population.Value)
Then drag and drop City field above details and below Country:
Finally drag and drop District field to right most column:
I have a SQL Server Reporting Services report that shows customer order data, but it's grouped as follows:
Store
Customer
Customer Order Items
So, each report is a grouping of stores, with a subgroup of customers per store, and then the items per customer. I'm trying to show aggregate sale and other information at each header record of the appropriate group in the report. Most of this is working well, but for each store header record, I want to show a count of the customers. I'm trying to use some variation and\or combination of RowCount, CountDistinct and other aggregate functions, but to no avail.
Can anyone help me determine how I essentially can get a "count" of customer groups to show at the Store level header? TIA!
CountDistinct on Customer should work fine - no need to specify scope if it's in the Store group header row.
I put a simple test together.
Data:
Report in designer:
Most important thing to note is the CountDistinct on Customer in the Store header row; this is just the expression used:
=CountDistinct(Fields!customer.Value)
End result, showing correct values:
Please let me know if I'm missing something.
Edit after comment:
Apologies in advance for how long this is getting.
The previous report did have row groups for Store and Customer, but I've modified this to make it more clear, hopefully. Still based on the same DataSet:
You can see there are three row groups, and each row in the report is actually a group header row belonging to one of those groups.
In the Store group header row I've kept that same CountDistinct expression. I've also added a CountRows() expression to show how many actual rows are available in each of the different groups.
Here you can see for Store1, CountRows is returning 4, i.e. there are four rows that we are aggregating in this scope, which is what we expect looking at the DataSet.
Similarly, when we apply =CountDistinct(Fields!customer.Value) in the Store scope we are considering these same 4 rows, and we see two distinct customers for Store1, which seems correct to me.
For Store2 we are considering 6 rows in total, which have three distinct customers. Again, just by applying =CountDistinct(Fields!customer.Value) we get correct value.
Hopefully this rejigged report helps clear things up. If I'm still not getting your requirements, can you please explain what numbers are wrong in my sample report based on my sample DataSet? That way I can adjust things easily on my side.
I have a matrix with several columns and rows. Example the rows are made up of names for a company and along the top are total sales, total calls, etc. So each row will have a number under each column, and at the bottom of each column is a total for each column. Currently i have the report set up that if you click on any of the numbers it pulls up a detailed report for those particular items. But if you select the total number it brings up the results for the first row's column. Is there a way to make it return all the items details when you click the total number for that column instead of what ever the detail would be for the first row of that column? Does this make sense?
You can use the inscope function to check whether you are in the value or total row. If you are not in scope then pass the correct parameter to the details report.