Adding Value Fields in a different data set in SSRS - reporting-services

In this question it answered how to add two different datasets,
SSRS - Expression using different dataset fields
I tried that kind of approach and here is my expression
=First(Fields!count.Value, "remclass1")+First(Fields!count.Value, "db_IACS")
the problem is that only the first value is being Calculated like this
I added the Pulled out COUNT to the Expired Count, i want it to be added per Row
only the first part
For instance:
Column 7 (Count) = Column1(Count) + Column 4 (count) //**per Row**
The value of row 1 column 7 would be column 1 + column 4 row 1
the value of row 2 column 7 would be column 1 + column 4 row 2
The Pulled out table
(Consists of Count, Grams, Principal) are on the data set db_IACS
and the Expired table(Consists of Count,Grams,Prinicipal) are in the dataset remclass1
So any help how to do it? how to add the two columns (in a different dataset)
Thanks :)

You could do this in SQL, as follows:
SELECT db_IACS.count as PulledOut_Count, db_IACS.Grams AS PulledOut_Grams, db_IACS.Principle AS PulledOut_Principle,
remclass1.count as remclass1_Count, remclass1.Grams AS remclass1_Grams, remclass1.Principle AS remclass1_Principle
FROM db_AICS
LEFT OUTER JOIN remclass1 ON db_IACS.Id = remclass1.Id
Then just deal with everything in the one dataset.

Related

SSRS Report - Badges

Is there an easy way to do a page of badges in an SSRS report? I am looking at 2 across and 3 down per page based on a list. I have built one so far of a single column using a list box but the problem is that it is not advancing to the next record and shows me the same record over and over until I get to the end of the count of total records in the dataset so I know I am doing something wrong. I am using Visual Studio 2017
I use a matrix when I am making a grid with boxes that go across and down.
First I add a ROW_NUMBER to the query to have the order in which to show the records. I subtract 1 so the values start with 0.
SELECT *, ROW_NUMBER()OVER(ORDER BY EFF_DATE) - 1 ROW_NUM
FROM BLAH_BLAH...
Then in SSRS, add 2 Calculated Fields to the dataset with the ROW_NUM.
The first is named ROW. It will have an integer with the row that the record will end up in.
=INT(Fields!ROW_NUM.Value / 2)
The second is COLUMN that will give the a column number.
=Fields!ROW_NUM.Value MOD 2
Then in the matrix, set the grouping based on the calculated fields.
COLUMN GROUP
Group and Sort by COLUMN
ROW GROUP
Group and Sort by ROW
The 2 can be changed to use whatever number of columns is needed.

SSRS, return rows into a grid layout

I have a dataset that I need to arrange into a grid on a page (export to pdfs) as a customer report. Each row in my dataset needs to display as a cell. Each page would have roughly 3 records displayed as columns and then 4 rows of records. e.g. a (3x4 grid), being 12 records per page.
Right now I am using a matrix to display my results, but I cannot find how to get my matrix to start a 2nd row after 3 columns are generated.
Is this feasible or should I find a different solution to create these reports?
I was thinking may be if I had row groups to use, but not sure how to create a column that creates a repeating result 3 times then adds 1 to the next 3 results in my query. 111,222,333,444 and that could be my row grouping?
Here's what I use in a matrix to create a grid of columns from a single cell.
Add a ROW_NUMBER field to the dataset query and subtract 1 with the ORDER BY using the field to be ordered by.
ROW_NUMBER()OVER(ORDER BY DISPLAY_NAME) - 1 AS ROW_NUM
Add Calculated Fields to the dataset using the ROW_NUM.
Call the first COLUMN and MOD row_num by 3 to get values or 0 - 2 for the column number:
=Fields!ROW_NUM.Value MOD 3
Call the second calculated field ROW and get the INT of ROW_NUM divided by 3 to get the row number for the record:
=INT(Fields!ROW_NUM.Value / 3)
Then the matrix would have the Column grouping (and sorting) based on the COLUMN field and the Row grouping on the ROW field.
You could use a parameter as the number of columns (3) to make it easy to change.

Resize tables based on number of records in SSRS

I have two table having data like below:
SELECT *
FROM [dbo].[TestTable_1]
ID Value
----------
1 gjha
2 dc
3 d
4 ds
5 dg
6 hn
2nd table:
SELECT *
FROM [dbo].[TestTable_2]
Value
-----
jklsa
dfv
b
grt
trj
h
muik
rg
kuu
wd
gb
nm
wef
I'm fetching the data in SSRS report as below:
Question is:
How can I maintain the table size same? That is, if small table in SSRS report has 6 records (which is in this case),
the bigger one should adjust same size as small and the extra (/more) records that are coming in the large table should shift to right.
Here is the expected output from SSRS
Value Value
-------- -----------------
gjha jklsa |muik | wef
dc dfv |rg |
d b |kuu |
ds grt |wd |
dg trj |gb |
hn h |nm |
Note: The above details are just example, however, the number of records are really dynamic.
This is not a full answer as it's just what came to mind and is completely untested.
First thing is to search SO for ways to create a multi-column table, there are plenty of answers already so I won't explain in detail here. They usually involve adding RowNumber to each row which you can then use to calculate a matrix row and matrix column number, the column number can be used in a matrix as the column group. (e.g. if the row limit is 6 and the row number is 14, that will have a final row number of 2 (14 mod 6 = 2) and a column number of 3 as Floor(14/6)+1 = 3.
Next, create dataset that just gets the highest row count from each of your tables. Something like
DECLARE #a int
DECLARE #b int
SELECT #a = COUNT(*) FROM myTableA
SELECT #b = COUNT(*) FROM myTableA
SELECT CASE WHEN #a<=#b THEN #a ELSE #b END AS maxRows
Now you have the size of the smallest table, you can pass that as a parameter to the proc that gets the actual data from the two tables (this would be 6 in our example above)
I just answered a similar question here: https://stackoverflow.com/a/56350614/2033717
You can adapt this solution to your situation by replacing the 3 in the expressions with:
=Floor(Count(Fields!ColumnName.Value, "Dataset1") / Count(Fields!ColumnName.Value, "Dataset1"))
In other words, you're determining how many columns you need. And then grouping each row of the dataset into rows and columns of the matrix. This will work if you know the second table can be bigger than the first, but I'm not sure if it will work both ways without some additional conditions on the expressions.

SSRS - how to create a double entry table

I need to create a report which is something similar to a Pivot Table.
The report would be something like below, with more towns
I C S Total
Town1 1 2 3 6
Town2 7 1 1 9
Town3 2 3 1 6
Total 10 6 5 21
In Crystal reports, there is an integrated function called Cross table
(see pictures below)
I'm looking for a similar function in SSRS, if there is any. I parsed the internet but I could not find anything that is relevant
Thanks!
You need a matrix to do so
Select the row, once the matrix created, like the image below and click on the row group and look at the group properties
You then choose the row for which you want to do the grouping like the image below
Repeat the operations for the column group.
You will need to add additional row and columns for the total.
I will do that for the row. You click the row to highlight it and then click on insert rows. You then choose Outside group below like in the picture below
Repeat the operations for the column group.
To have total, please put the following formula in your row and column created outside of the group SUM(COUNT(Fields!name_of_your_field.Value)) and you have the double entry table.
Let me know through the comments if you have any issues, I'll happy to help.

Count number of row results for a row group

How do I group/filter rows and then get total rows for each column. I am going to diagram what the result should be. I don't want to show the actual data. Just the count per column
Out Put should look like this
Column A Column B Column C
Row A - 235 records 300 records 15 records
Row B - 1 record 80 records 900 records
Each column represent a count on the same field but filtered.
So ..
Column A is really Count(MyColumn) WHERE = A
Column B is really Count(MyColumn) WHERE = B
To summarize each row is a grouping + filter and each column is a count based on the number of rows contained in that grouping. No row data needs to be displayed.
You can do this in a table in the group by using the following formula:
=SUM(IIF(Fields!MyColumn.Value = "A", 1, 0))
However, this type of summary report is what a matrix is designed to do. Use the Row field as the row group, the column field as the column group and a Count expression in the intersection and it will do it all for you.