How to do SUM(VacancyID) without Duplicates while also showing Count(VacancyStartID) in the same Group? - reporting-services

In SSRS 2005 I am reporting on all available posts by regional office, listed by region,office,vacancyID.
I then display a total per office on how many people started in a particular vacancyID by doing a Count(VacancyStartID).
In the same group row with the Count(VacancyStartID) I need to display SUM(VacancyID).
However at present this does not give the correct SUM, because some vacancies have multiple VacancyStartID's and hence the vacancyID is listed few times, like so:
office vacancyID Number_of_vacancies VacancyStartID (person who started a job)
1 1 2 4567
1 1 2 5678
Totals: 4 (needs to be 2) 2
P.S. Note:These questions are not applicable in this instance:
How can I remove duplicate rows?
How do I remove "duplicate" rows from a view?
Using multiple COUNTs and SUMs in a single SQL statement

If it's in the Underlying SQL Server call...
You can do ...SUM(DISTINCT VacancyID)... like you can COUNT (DISTINCT ..)
Edit:
SELECT
col1, col2, SUM(DISTINCT Number_of_vacancies) as foo, COUNT (VacancyStartID) as bar
FROM
MyView
...
If it's in the table or for a cell in the report, then there is no equivalent in the SSRS SUM function.

Do some grouping already in your query and then make a group with a simple Count in SSRS.

Related

SQL Report Builder for Survey Data

I have a large dataset with People's names and their Rating from 1 to 5.
Then I made a query that summarizes this data for PersonA:
Rating Count
------- ------
1 4
2 6
3 1
4 0
5 2
I just need to know how to show this on my report.
I have made a cell for each rating and need to put in an expression that says "If Rating=1, show count for rating 1".
I tried using =IIf(Fields!Rating.Value = 1, Fields!Count.Value, 0) but this didn't work.
I'm not sure why you would need an expression like that, based on your description of the dataset it sounds like you already have two columns of data for rating and count, so you could use a tablix (table), with columns:
Rating Count
which would list all the rating values and associated count values, similar to the example result in your question.

Merging multiple Rows in ssrs report to a single one

I need help regarding SSRS Reporting my data is Coming from a Query and I also have added the Column Group Named as Subject Name Showing on the top of the Table() Also Added ApplicantID as Row Group and FName as a Row Group in the Report to fulfill my requirement that was just to show
Since I am not Sure how many subjects a user can select its all decide on the run time so i did added the Subject name as a column group
All the Subject records in a single row for a specific ApplicantId Instead of showing below my Requirement is
It Should looks like as a table
Anatomy Surgery Zoology
Part ISt
14 Hanan Qureshi Iqbal Qureshi 15.00 20.00 10.00
15 Tasneem Alam Imtiaz Alam 30.00 10.00 20.00
etc instead of Showing in a seperate row it should show in a single row
Details group is your problem as #hemanth said you need to remove this and add in an aggregate function (max, min, sum, average) any will work since there is only one value for each SubjectName, Obtained Mark Combo. this will give you all the marks on one line for each applicant.

ssrs count error getting 1's instead of total

Rookie mistake,
here it is:
I got Regions and MembersID, I grouped the regions and want to count the members. When I add the count(MembersID) instead of geeting the total members, I get a bunch of 1:
RegionA 1
1
1
RegionB
1
1
what I want:
RegionA
3
RegionB 2
what I did: Grouped Regions and Count[MembersID]
Please help!
It's a bit tough to tell what you actually need here.
In Group Header rows, you can use aggregate functions, which will look at all rows in that current scope.
Distinct MembersID count in group: =CountDistinct(Fields!MembersID.Value)
Total rows in group: =CountRows()
In detail rows, these aggregate functions will only report on the current rows, so =CountRows() will only ever return one; to get the number of rows in the group you need to set the scope of the function to the group level, e.g. something like =CountDistinct(Fields!MembersID.Value, "Group1") or =CountRows("Group1").
So based on a Dataset:
And a report which incorporates these aggregate function in the group header and detail rows:
You can get the following results:
If this is not sufficient you will need to supply your Dataset details, some sample data and how you need this sample data presented.

Sum of distinct in SSRS

I have to get distinct rows sum in SSRS expression.
**StudentId TestScoreMath CurriculumEnrolled EnrollStatus**
100 200 Nursing Enrolled
100 200 Physical Enrolled
200 100 Tech Enrolled
Total Student TestScoreMath should be 300 not 400. I tried using the expression
=Sum(Fields!TestScoreMath .Value, "table1_Group3")
How can I SUM the value of TestScore of distinct students? I need this only in SSRS.
In SSRS 2005, this is not too easy. I would add embedded code to keep a running total. You can have the custom code to check to see if the current student ID matches the last. If so, then don't add another test score to the total. Or you could group by Student ID and call your custom code only in the header or footer of that group.
This sample shows totaling all rows: you'll need to add to this to track the studentID.

Reporting services put data from two DataSet rows in one tablix cell

I need to create report with table which looks like this
Country 1 Country 2 Country 3 Total
Category 1 1(2) 2(1) 5(6) 8(9)
Category 2 2(3) 2(1) 4(0) 8(4)
Category 3 3(2) 2(1) 3(1) 8(4)
Total 6(7) 6(3) 12(7) 24(17)
Report contains data about TFS WI's and has information about current week's WI count and last weeks WI count (in brackets)
Data set on which this report is based on MDX query against TFS warehousw cube and has such structure:
Category Country Week Count
1 1 this 1
1 2 this 2
1 3 this 5
1 1 last 2
1 2 last 1
1 3 last 6
Trouble is, I cann't find a way how to concatenate data about current and last weeks incident count in one cell. I have toyed around with idea to do it in MDX, but with my limited MDX skills I can't see how it could be done.
Rowgroup on Category.
Columngroup on Country.
Inside the cell you should be able to have 2 placeholders with the second one in brackets. The first expression should be:
=Sum(iif(Fields!Week.Value = "this", Fields!Count.Value, 0))
The second one should be:
=Sum(iif(Fields!Week.Value = "last", Fields!Count.Value, 0))
In MDX you could create two calcs - this and last week (of course you'll need to change this to work with your cube):
WITH
MEMBER [Measures].[thisWeekCount] AS
([Date].[Week].[this], [Measures].[Count])
MEMBER [Measures].[lastWeekCount] AS
([Date].[Week].[last], [Measures].[Count])
SELECT
{
[Measures].[thisWeekCount],
[Measures].[lastWeekCount]
} ON 0,
{
...
} ON 1
FROM [Your Cube]
Then, you can use them within placeholders as jimconstable explained, but without the iif functions.
Thank you all for your answers!
I found out that main problem (reporting services allows only one measure on columns) can be solved by using Analysis server OLE DB provider. There are some drawbacks, like that parameters are not supported, but I can live with this.