Aggregation with nestged groups in SQL Server Reporting Services - reporting-services

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:

Related

How to fetch data in a Single SSRS report using Multiple Dataset

I was trying to create SSRS report with a country map and a table. Country Map for showing total Number of Cases state wise and a table to show the total number of Cases in the whole country on the Top Middle side of the Report. Both (Map and Table) Using Different Datasets.
When I run the report to preview the data, It gives me an error:
The Endvalue expression for the map uses an aggregate expression without a scope. A Scope is required for all the aggregates used outside of a Data region
However, I have also tried to use the first dataset to calculate the Sum of all cases in the country.
But it shows the data in the table state wise not the Complete Sum.
=Sum(Fields!Total_Cases.Value)
I have read some issue similar to this topic but unable to implement them.
For displaying total cases in the table I have also mention the dataset name but not getting result.
=(Fields!Total_Cases.Value, "Dataset2")
Please suggest the correct way..

ConcatRelated Returning Multiple Values

I am new to MS Access and am trying to build a database that includes a text roll up (effectively summarising staff feedback collectively to the manager). I have set it up using ConcatRelated (http://allenbrowne.com/func-concat.html) and this works as expected. The only issue is that I cannot seem to ensure that only the first instance of a value is returned, rather than every instance. For example:
The function is bringing back the top view, but I only want it to bring back the Distinct values - please note, as this is a manager view, the same value can appear multiple times in the data retrieved. As such, I almost need the text to de-dupe if it is already there.
Full disclosure - my SQL is not great, so I am using the Expression Builder from the design view
Any help will be appreciated
EDIT for more detail:
The image shows a sample of the data and the output. In this, Mary is the team leader and so is responsible for the areas of John, Steven, Erin, and Harriet. The UID refers to the responsibility area.
As you can see, the dataset has the "minimum target" referenced against the area of responsibility and the output I am getting is duplicating the comments (which I presume is because the value is returned twice), but I am trying to ensure that commentary is summarised, not duplicated.
Note, in the summary output, I am not interested in the areas of responsibility, just the commentary against the staff names.
I hope that makes sense
Build a query that retrieves distinct Comments values for each person:
SELECT DISTINCT Person, Comments FROM table;
or
SELECT Person, Comments FROM table GROUP BY Person, Comments;
Now reference that query in ConcatRelated function as source for Comments values.
Be aware that calling a function like this in query along with aggregating can cause slow performance with large dataset.

SSRS mutiple database source to be joined

Just stuck on getting information from two sources, we have a MYSQL database for repairs information which I have in SSRS, this brings back 7000 rows. We have another Repairs database in Oracle which brings back over 3 million rows.
I can't seem to bring the one from oracle as it exceeds the maximum limit, but is there any way do a left join using so i can bring only the two columns i need from the oracle one into the MySQl one which would mean i have 7000 rows plus the 2 columns from Oracle which have a common Primary key. I can't seem to join on two dataset with it being on two database.
Can anyone help.
THank you in advance
You can use the Lookup function in SSRS to find a value from one dataset based on a common key.
=Lookup(Fields!SaleProdId.Value, Fields!ProductID.Value, Fields!Name.Value, "Product")
Use Lookup to retrieve the value from the specified dataset for a
name-value pair where there is a 1-to-1 relationship. For example, for
an ID field in a table, you can use Lookup to retrieve the
corresponding Name field from a dataset that is not bound to the data
region.
(BIDs Description)
In the above example, the SalesProdID from one dataset is being used to relate to the ProductID in the Product table to get the Name field.
This will only return one value, though. This may or may not be OK depending on your data. If you need to return multiple values, use LookupSet.
=LookupSet(Fields!TerritoryGroupID.Value, Fields!TerritoryID.Value, Fields!StoreName.value, "Stores")
Use LookupSet to retrieve a set of values from the specified dataset
for a name-value pair where there is a 1-to-many relationship. For
example, for a customer identifier in a table, you can use LookupSet
to retrieve all the associated phone numbers for that customer from a
dataset that is not bound to the data region.
Unfortunately, you might need to SUM a Lookup but that isn't supported by a function in SSRS. Fortunately, users created a function for it:
SSRS Count Occurances based on multiple columns

SSRS recursive hierarchy expression to return the pre-determined value of the layer in the hierarchy

I have a SSRS report that uses a recursive hierarchy. The bottom row shows the Store, the row above is the state, the row above is the country. In the first data column, I've successfully calculated the Qty of sales on the state and country rows using the expression
=Sum(Fields!Vol_Current_Wk.Value).
My problem however, is I need to include another column that returns a pre-defined measure. The tricky part is the state and country results are already calculated, and is not based on a calculation I can replicate using the store level data. I tried using the expression =Fields!QTV_Wk.Value, on the state and country rows, however this is not returning the correct results on these layers.
I can create 3 separate reports, one for store, state and country, and use the expression =Fields!QTV_Wk.Value to return the correct results, but the preference is keep as a grouped report to make it easier for the end user to read. I'm hoping that a report that uses a recursive hierarchy grouping can have an expression that will return the value already pre-defined for each layer of the hierarchy.

SSRS select parent parameters based on child

I need to implement a SSRS report where I need to select values in my parent dropdowns based on the selected value of the child dropdown. My question would be more clear after the following example.
Assume I have 3 multivalued parameters in my SSRS report, Continents, Countries, and Cities.
On report load, the Continents parameter will be populated with all continents, Countries parameter will be populated with all countries, and the Cities parameter will be populated with all cities. Now if a user directly selects a city, I want to update the Countries and Continents parameters with the relevant values.
For e.g., if I select New Delhi in the Cities parameter, India and Asia should get selected in the Countries and Continents parameter respectively.
I hope my question is clear. My requirement involves several more dropdowns, but if it works for the above case, I think it would work for me.
Is this possible?