Display data in single column - reporting-services

I have a table as shown below:
Table 1
I need to display data like below. I have tried using grouping but but i failed.
I have read some topics but can't find the solution. This should not be that hard.
Table 2

You can get that using LookupSet over a dumb group.
Add a tablix to your report and add a parent group in the Row Groups pane.
Use the below expression to create the group.
=1
That expression will create only one group, and you will have something like this in design.
Then use this expression in the highlighted cell in my screenshot above.
=join(
LookupSet(1,1,Fields!ColumnA.Value,"DataSetName")," - ")
Where Fields!ColumnA.Value is the field of X, Y and Z values, and DataSetName should be the name of your dataset.
You will get this result.
If you have repeated values in ColumnA they will appear repeated too in the cell. You will have to filter your dataset to get only unique values.

Related

Report Server (ssrs): retrieve column name by query

Would you help me, please, to retrieve column name by query.
In the report I want to show columns by condition.
I created a parameter #cols, which contains the list of column names (multiple values are allowed).
In column visibility/show or hide based on expression I added:
=IIF(InStr(Join(Parameters!cols.Value, “,”), “My_col_name”)=0, true, false)
This works perfectly, but for each column I should insert in the row above the original column instead "My_col_name".
Since my report has hundreeds of columns, it looks annoyying.
Is there a method to simplify this task? E.g. to insert instead "My_col_name" some expression, which shows selected column name?
Thank you.

How to get total from another tablix column? (SSRS)

Hello awesome people of stackoverflow!
I need help with a simple problem with my SSRS expression.
How could I do this in SSRS?
As you can on the 2nd table below in my excel screenshot.
for each row we divide -BC5...-BC10 to column/row BC4. To get the desired results for table 2 in excel column total 2018 into column/rows BC17 upto BC22.
I've tried referencing my textbox like this
ReportItems!TextBox1.Value / ReportItems!TextBox2.Value.
But got me the wrong values.
Can someone please help.
Thank you!
If those two tables are in the same table/tablix then it should work with the expression that you wrote (try to type it instead of copy paste sometimes that may work).
=(ReportItems!Textbox7.Value /ReportItems!Textbox1.Value) * 100
If they are not in the same Table/Tablix then you should write like the following:
=(Fields!ColumnName1.Value / Fields!ColumnName2.Value) * 100
Format your cells.
There is not enough info to give you an exact answer but you should be able to work it out.
The first thing you need to do is get the context of the aggregations you want to work with. So click on the cell containing the number you want to divide ([Sum(DiscountOERestated)] ). In the row and column groups panel near the bottom on the screen, look at the row group that is highlighted. For this example I'll assume the row group is called grpCategory.
Now we need to do the same for GrossCatalogRestated. However, GrossCatalogRestated in the top tablix does not appear to be an aggregate. I'll assume it should be the total GrossCatalogRestated for the dataset. For this exmaple, we'll say the dataset name is dsMyDataSet. If it's within a row group, just swap the dataset name out with the row group name that it sits in, just like we did for DiscountOERestated .
So you expression would look something like
=SUM(Fields!DiscountOERestated.Value, "grpCategory") / SUM(Fields!GrossCatalogRestated .Value, "myDataSetName")
This will give you a deicmal result, somehting like 0.025 . You then just need to set the format property to say, "p1", so it shows as 2.5%
If this does not work, edit your question to show the expressions in the cells you are working with along with the rowgroup and dataset names.

ssrs 2008 sort data based upon parameter value

In an existing ssrs 2008 report, I have added a few new columns to the existing report as requested by the user. In addition, the user wants to be able to sort the data on any column on the report by using a sort parameter value.
The data does not contain any summary values. The columns in the report include:
a. student number,
b. student name,
c. birth date,
d. age,
e. current grade level,
d. attendance code value.
The default value is to sort by student name alphabetically. Whatever field is to be sorted first, the student name will be the second.
I have tried to sort the data at the tablix level and the row group level and the logic has not worked yet. There is no row group setup right now.
Thus could you show me how to setup the sort by using the parameter value? Would you show how the ssrs report needs to look for me to accomplish this goal and/or point me to link(s) that will show me how to accomplish this goal?
On the row group's Sorting, set the Sort By to use the Sort parameter to determine which column to sort, like:
=IIF(Parameters!SORT.Value = "NUMBER", Fields!STUDENT_NUMBER.Value,
IIF(Parameters!SORT.Value = "NAME", Fields!STUDENT_NAME.Value,
IIF(Parameters!SORT.Value = "BIRTH_DATE", Fields!BIRTH_DATE.Value,
IIF(Parameters!SORT.Value = "AGE", Fields!AGE.Value,
IIF(Parameters!SORT.Value = "GRADE", Fields!GRADE.Value, Fields!STUDENT_ATTENDANCE_CODE.Value)))))
Set a second SORT to use the Student_Name field.
Did you try using interactive sort. That way users can sort on any column in the table. In my experience this has worked perfectly well.
Here is more info- (the first section is what i think you would need - Sorting Detail Rows for a Table with No Groups ) -
https://technet.microsoft.com/en-us/library/cc627509(v=sql.100).aspx
Let me know if that was helpful.
Select the tablix, right click and click on Tablix Properties
Go to the Sorting Tab. Click Add (below the Change Sorting Options)
Now select the order or click expression and write an expression to sort the columns based on parameters supplied.
Click Ok
In the order select A to Z ASC or Z to A for DESC
You need to select each column and select A to Z or Z to A
For example
In the expression,
IIF(Parameters!SORT.Value = "NUMBER", Fields!STUDENT_NUMBER.Value,"")
In the order column select A to Z or Z to A

SSRS Report Builder IIF error with aggregate

I've been struggling with an IIF error when trying to create a variable aggregate.
I'm using Report Builder 3.0
I have a report where users determine what fields are in a report. These fields are passed as a multivalue parameter. I use a lookup from a different dataset to determine its placement in the report, and using the same order dataset to determine if the field is numeric or not (meaning I want to sum the value based on row-level grouping). The headers pull in using the same field lookup, which works fine. At the row level I'm trying to return either the sum of the field value based on row grouping, or if non-numeric, return the value. Based on similar posts I understand that both the true and false parts are processed. I attempted to offset this error by nesting another IIF. If I remove the sum function the data returns non-numeric data fine. However if I include the sum function numeric data is processed fine however non-numeric data returns #error.
What am I missing?
Here is a definition of the data I'm referencing below:
lookupvalue: returns the fields selected by the user based on predefined order in a stored procedure.
Fieldisnumeric: indicates if the field selected is numeric or not, 0 is false, 1 is true
Fielditem: the field item in the tablix being referenced
dtsselectedfields: the dataset I'm looking up the column order and numeric properties of a field.
The number 1 indicates the first position in the variable count of fields selected by the user. Additional fields are hidden based on the count of fields passed in the parameter and are incremental (e.g 1-n).
=iif(Lookup(1, Fields!LookupValue.Value,
Fields!FieldIsNumeric.Value,"dtsSelectedFields")=0,
Fields(Lookup(1, Fields!LookupValue.Value, Fields!FieldItem.Value,
"dtsSelectedFields")).Value,iif(Lookup(1, Fields!LookupValue.Value,
Fields!FieldIsNumeric.Value, "dtsSelectedFields")=0,
Fields!MV.Value,sum(Fields(Lookup(1, Fields!LookupValue.Value,
Fields!FieldItem.Value, "dtsSelectedFields")).Value)))
****edit 12/1/2015****
For additional clarity, I'm providing additional details. Below is 'dtsSelectedFields' dataset.
FieldItem_____LookupValue_____FieldIsNumeric
Item1Desc__________1__________________0
Item1Total__________2__________________1
Item2Desc__________3__________________0
Item2Total__________4__________________1
Let's say I have one column of data, and this column would first look for a LookupValue of 1. This would return the FieldItem, 'Item1Desc'. Because this field is not numeric, I would want to return the value of Item1Desc. However let's assume my first selection was actually 'Item1Total' and I don't want to return the non-numeric Item1Desc field. In this case, because 'FieldIsNumeric'=1 indicating a numeric field, I want to take the sum of this field.
Is it possible to nest an aggregating function in an IIF statement on only one part of an IIF statement? I.e. the true part or false part?
And if so, what am I doing wrong?
An example of the tablix:
sample layout
Column 1 Header____________Column 2 Header___________Column 3 Header
Column 1 Data______________Column 2 Data_____________Column 3 Data
Sample data
Product___________________Country of Origin_________________Units
ABC Envelopes___________________China______________________15
LMN Packets_____________________India_______________________30
In the example above, user selects 3 columns, 'Product', 'Country of Origin', and 'Units'. There are other fields available that would cause multiple rows if I grouped by them in the stored procedure (for example acquisition price). Based on the lookup I return the column description as a header. The row-level detail is described as above (e.g. Return the product name and country of origin, but sum up the units).
As a workaround for my issue above, I found an (ugly?) solution.
As mentioned above, a user can select any number of columns and the report organizes them in columns based on a predefined order according to a stored procedure. (E.g. a product description would come before the sum of the units if those two columns were chosen, but a product ID may come before the product description, but only if the ID was chosen.)
For every possible number of columns a user can select, I added two columns in the report (i.e. two for each field).
The first two columns will reference the lookupvalue=1. I then set the expression of each field in the detail to 1) a sum of the value, or 2) the value itself. I then set the column visibility to the results of the 'FieldIsNumeric' column. So the summed numeric column which would return an error for non-numeric data would be hidden when FieldIsNumeric=0, and the non-numeric column referencing the lookup value =1 would be shown, and vice versa.
Needless to say additional columns would follow the same logic in sets of two, each referencing the sequential lookup value (e.g. columns 3 and 4 would reference lookupvalue=2, columns 5 and 6 would reference lookupvalue=3, and so forth. Each column within the matching pair would be displayed or hidden based on the returned value of FieldIsNumeric in the same lookup dataset.
I'm definitely open to suggestions, but thought I'd post this as a workaround solution.

SSRS Filter with a different column from a different dataset

I want to filter my column, let's call it AllStudentID from dataset1 with another column from a different datset.
Dataset1 had many column such as AllStudentID, Class, Time, Location.
Dataset2 has other columns but i'm focused on a similar column called OnCampusID.
I've tried looking into using a filter but since the report itself has the columns from Dataset1, i run into an issue where if I select the column in dataset2, it always gives a First(OnCampusID). And I don't want that.
I looked into IIF() but again, i'm using a column from a different datset plus if let's say that they are NOT equal, I don't want to display anything, instead of putting something there. I know that you have to put a result if true and a result if false.
If I"m thinking of it in terms of SQL statements, it's like having a WHERE clause WHERE AllStudentID=OnCampusID.
I tried running a Parameter but I don't want the select part on the top but rather have the report filtered already.
Am I missing something? I know it has to be simple.
Mind you, the following example above is just an example i made up, not the real thing.
Assuming that each OnCampusID only appears once in Dataset2 then you can do a Lookup expression to filter it:
=IIF(IsNothing(Lookup(Fields!AllStudentID.Value, Fields!OnCampusID.Value, Fields!OnCampusID.Value, "Dataset2")), False, True)
If OnCampusID appears more than once in Dataset2 then do the same thing using LookupSet.
To get the graduate field from Dataset2 just to a Lookup in the Value of the cell, like so:
=Lookup(Fields!AllStudentID.Value, Fields!OnCampusID.Value, Fields!Graduate.Value, "Dataset2")