Grouping by first letter in reporting services - reporting-services

I have a report which lists the employee list. I want to show the list as below;
A
-----------------
asdas
adfgs
artret
B
-----------------
bifjgdifg
buasüdp
bpopo
C
----------------
cxasdas
coierewf
clasdksa
How can I integrate this grouping type into mine report.

You could do this in the SQL statement that returns the data by adding an additional column that only contains the first letter and is invisible in the report - group by that column then.
Another way could be to change the group-field in the report's group to not group by for example =Fields!Name.Value, but use a string manipulation function to group by only the first letter. For example you could try
= LEFT(Fields!Name.Value, 1)
for the grouping.

Related

Lookup using textbox value as source showing too many rows + SSRS

I did a lookup function in ssrs where the source is a reportItem reference. I want to return the value from the table that I am looking up based on the reportItem reference. The report is retrieving the correct values, but and I'm getting repeated rows and I'd like to know if there's a way to eliminate that. My parameters in the tablix is based on a ticket number.
The underlying data has 3 transactions but 9 rows are currently being returned.
In SSRS, my query is:
Select
ticketno, name, control, value
from ticket a
inner join details b on a.ticketno = b.ticketno
where control like 'LS%' and ticket = 'ED08'
The return result contains 4 rows transactions
ie:
Ticket
Name
Control
Value
ED08
Eng
LS1
A
ED08
Acct
LS2
B
ED08
Med
LS3
C
In SSRS, I used a table and hard coded the Name as it's possible that there will be no values.
I hard coded Eng, Acct, Med, Dent for names.
I entered an expression on each individual row with an expression
=lookup(ReportItems!textbox.Value,Fields!Name.Value,Fields!Value.Value, "UDF_Det")
However, when I run the report, I get extra rows.
The transactions retrieved from the ticket in SQL only retrieved 3 rows, so I would have expected that. Is there a way to filter on row specific data?
I have looked at this post Adding values to a Report when there is no Data in query SSRS but since I am not doing any calculations I'm not sure why I am getting repeat rows.
My design looks like this:
Output looks like this:
Acually, now I've edited your question I understand the problem. :)
You can just get a list of Name and left join from it to your existing query.
You maybe able to get the list from an existing table (hopefully) or you could hardcode one (avoid if possible).
Assuming all the Names you need are in your ticket table you could use something like this...
SELECT DISTINCT [Name] FROM ticket
(if name comes from another table, just change the query to suit)
then left join your existing query to this, something like
SELECT n.[Name], t.ticketno, t.control, t.value
FROM (SELECT DISTINCT [Name] FROM ticket) n
LEFT JOIN (
Select ticketno, name, control, value
from ticket a
inner join details b on a.ticketno = b.ticketno
where control like 'LS%' and ticket = 'ED08'
) t
ON n.[Name] = t.[Name]
which should give you something like
Name
Ticket
Control
Value
Eng
ED08
LS1
A
Acct
ED08
LS2
B
Med
ED08
LS3
C
Dent
NULL
NULL
NULL
Then you can simply have one row in the detail group in your table to output the results.
If this does not help, post some sample data from your database tables and show the full report design including row groups etc

RDL a group for both row & group column

i have an RDL contains 1 row group and 1 column group
I want to create one more group which wrap both this 2 group
So that group X will be created, and records of row group A & column group A will generate base on group X.
but i found no solution to add that group X.
Is there any solution to do it? or it is impossible in RDL?
Above is the expected result with some important points
A is row group,
C is column group, the string C, C1 ,C2,C3 are actually the data from the same dataset with A, just the grouping parameter is not the same
DATASET
Below are the interesting requirement:
for each group of A (lets say A1&A2), it will display in a new page (ie. new tabs in the SSRS)
there is total row for each row group member
As mentioned C - C3 are generated dynamically based on the dataset. There are total for each group of A and requires to aggregate the sum for both rows,
thus C somehow need to cater the filtered dataset of A, and display the sum
The problem is:
In the page of A1, C1 & C2 will be blanked. C & C3 contains value
In page A2, C & C3 will be blanked and C1&C2 can be displayed
In fact, for the blank column ( for example A1), even the string C1 & C2 also unable to display as A1 didn't contain the data of C1 & C2 at all
I think what you want is not an additional group, but you want to nest your tablix inside of a list object. There's not any way to add both a column group and a row group inside of a universal grouping unless you use another control item. Then, you can add the grouping on the list item and it will do what you need. In the image below, you can see that my tablix is inside of a single row of a list object and the list object is grouped by a master ID for this report. This allows the inner row and column groups to expand as necessary, but separates them based on the master ID. I also put page breaks on this list item to put each ID on a new page.

Adding values to a Report when there is no Data in query SSRS

I have a query that returns Sales representatives number, Category, Sales.
The result is something like this:
There are 4 categories called G1,G2,G3,G4.
As you can see the Sales representative 11 sold 10 each category (Yellow rows).
But Representative 12 sold only for category G3 and G4.
The idea is to show in the report all the categories and populate with 0 all those who did not sell on that particular category.
It must be grouped by Sales Representative so if you make a tablix grouping by Sales Representatives you will have something like this:
But you want something like this:
Is there any expression I could use to add these?
What I did so far is to create a group, that group of course are my Sales representatives and combine the cells for that Column and created a Row group for each category, is something like this:
But if you execute that report it will repeat all categories G1,G2... For each time that category exists for that particular Sales Representative.
Another problem is, how can you evaluate The hardcoded category in your report if it does not exist in your datasource you cant make Iif("G1" = Fields!Category.Value,Fields!Sales.Value,"0") as you are not comparing G1 with Null or IsNothing, you are comparing what it exists.
I think you can achieve this smoothly using T-SQL at query level. I don't know why you don't use the simplest way to apply this kind of logic since in T-SQL you can use almost every logic.
However I like this kind of challenges so I come with this possible solution.
This is my sample dataset:
In SSRS dataset (not in T-SQL) I've added a calculated field called Another
Another field is set to the below expression:
=Fields!SalesRep.Value & "-" & Fields!Category.Value
I've added a tablix with the following data arrangement
As I mentioned before category field is hardcoded, the right column with Sales
is set to this expression:
=iif(IsNothing(lookup(Fields!SalesRep.Value & "-" & ReportItems!Textbox62.Value,
Fields!Another.Value,Fields!Sales.Value,"DataSet7")),0,
lookup(Fields!SalesRep.Value & "-" & ReportItems!Textbox62.Value,
Fields!Another.Value,Fields!Sales.Value,"DataSet7"))
Note: ReportItems!Textbox62.Value corresponds to textbox where G1
was hardcoded. You have to replace the textbox reference for the
corresponding in your tablix for every category.
It will preview the below tablix.
Let me know if this was helpful.

SSRS report - add extra table and chart to show occurence of character string in one of the main report's columns

I have an SSRS report based on stored procedure dataset. The report shows employees and their performance rating and uses bunch of parameters to filter the data.
Now I would like to add a table below that would dynamicaly count and show occurence of given mark in the main report. The table data should update according to what is visible in the main report after filtering it.
I wanted also to add a chart that would visualize this.
It would be feasible to do if the extra table and chart could run from the same dataset as the main report. This however seems impossible as this dataset does not always contain all the possible marks. It can happen that some marks are missing (when filtered or missing at all), and I would like to show the mark with zero value (and zero value bar in the chart) instead of just skipping it.
So far I was able to produce the table by hardcoding the headers and using SUM(IIF...) expressions under each header
Here is the expression for the "C" column.
=Sum(IIf(Fields!current_performance_rating.Value = "C", 1, 0))
It shows correctly the number of "C" marks appearing in the main report.
Now I am stuck with creating a chart that would show this.
I am not able to hardcode expressions similar to the ones in the table
and can't make the chart run from the main dataset, because the categories
would be missing after filtering the report (and not showing zero).
I tried linking datasets with Lookup function, but that did not work.
Which way should I go now? What is the best practice in such case?
Thank you for any hints!
Thanks trubs.
I have right joined a view that contains
all the marks and that solves the issue
of missing categories.
The join is on something like
tb.current_performance_rating = vw.performance_rating_code
I can now add the value series that counts
the occurence of current_performance_rating
per category. This works all fine.
However there is another table joined
(on employee_id) that stores last year's rating.
This rating obviously may differ to the current one.
On the same chart I would like to add another
series that counts last year's rating per category.
The category is there already, joined to the current
rating.
So you can have row like:
curren rating | last year's rating | category
C | H | C
So I am stuck, because when SSRS groups per category
it counts last year's H rating and displays
i the C category, while it should display it in H.
Sorry I can't post any pictures, seems like I
need more reputation points.
Hope you can understand what I mean.
Regards!
You're likely better off changing your query to return results for marks where there are no values.
So instead of inner joining to your Performance Rating table, use a Right Join or Full Outer Join, so that all the data is always available.
eg: Instead of...
SELECT p.PersonId, PersonName, g.Grade
FROM Person p
INNER JOIN PersonGrades pg ON p.PersonId = pg.PersonId
INNER JOIN Grades g ON pg.GradeId = pg.GradeId
Use
SELECT p.PersonId, PersonName, g.Grade
FROM Grades g
LEFT JOIN PersonGrades pg ON pg.GradeId = g.GradeId
LEFT JOIN Person p ON p.PersonId = pg.PersonId
If that's not clear, post your query and we could help get the data in the right format.
The way to go was to simplify the dataset that the main report was based on.
Then I took the query from that dataset, used COUNT and GROUB BY to count number of occurence of each current year mark in the main report. Then I right joined (thx trubs!) with the view that contains all the possible marks (so that my extra table headers/chart categories would not disappear if they do not exist). As a result I got the number of occurence in current year per mark (table A).
Then I did almost exactly the same for the last year's rating, just used last year's mark. I got the number of occurence of last year's mark per mark (table B).
I inner joined table A and B on common column (the mark, which will always appear thanks to the RIGHT joins). This gave me a table (dataset eventualy) where I had:
mark | current year mark count | last year mark count.
Making a table and chart basing on this was really easy then.
There was some more fun of adding all the parameters from the main report to both the count queries, so that the counts would change when report is filtered. I also needed to make sure that count works not only when my filter criteria (in WHERE stetement) equal the parameter provided from the report, but also when they are NULLs (so I added OR column_i_filter_on IS NULL).
This works smoothly - the table content and chart changes when filtering changes (although runs slowly, as parameters are passed to two big dataset, one of which uses them twice).
Thanks for all the help!!
psh

Total of unknown categories in SSRS 2005

I am working with SSRS2005. I have requirement to display total in the footer. We have to display the total of each category. What I used to do is, write expression for all category names and hide those totals that are not having any value in the current selection.
Mango Count = sum(iif(fields!Category.Value = “Mango”,0,1))
Apple Count = sum(iif(fields!Category.Value = “Apple”,0,1))
However, in the new requirement, I don’t have the knowledge of categories. It could be any number of categories. Is it possible to write an expression for this?
Please help
Thanks
Lijo Cheeran Joseph
Remove the footer from your table. Create a second dataset that sums by group (Select Fruit, Count(*) AS FruitCount From Fruits Group by Fruit), then add another table below your current table which uses this new dataset and displays the results.