Textbox to Get Specified Value from dataset in SSRS - sql-server

I want to get a specific row value from a specific dataset using the First function in SSRS.
The dataset returns values like:
From To Value
1 30 10
30 60 20
60 100 30
Also:
I have a parameter that has an integer value from 1 to 100.
I want to get the dataset value if the parameter is between From and To and
I want to put this value in Textbox not in a Tablix.

You can try this Expr in your textbox:
=First(Fields!FieldName.Value, "YourDataset")
Example:
=First(Fields!Name.Value, "GetName")
It worked for me.

This should work:
Use the parameter as two filters on the dataset, >= From and < To.
Then an expression in your text box like =First(Value.Value, "dataset").

You should first create a list (in order to relate to it a DataSet).
Then, inside the list, put a textbox and define the following expression:
=First(Field!Value.Value)
This will do the job :)

SSRS is a reporting tool not an application. You can either write your queries or SP to receive the value before generating the report, or otherwise i would recommend an application with a exporting functionality (you can even manipulate this to use SSRS to export your final report). Third party tools like Telerik can also maybe help.

Related

How to display a multi-valued parameter onto a SSRS report in a specific way, separated in ranges and/or commas

In SSRS I need to display a multi-valued parameter onto the report in such a way that if values are chosen in sequence they appear as: 1-5, 7, 9-10, 15 and so on. And I have the following values in my drop down list of values: from '0' to '200'.
Thanks in advance for your help.
This is what I have done in SQL so far, so I am thinking to update 'String_To_Use' column so it would display: 0000-1020, 1199-1210, 1260, 1299. Then use this string to display onto the SSRS report. These are the values chosen in SSRS from the drop down box. I don't know yet how I would pass these values to the SQL code yet. Please help with this part as well.
This is the #tempTable1...column 'DPRTMNT' has the values chosen ...Checking_Dept has the value-2 when values in ranges
This is the #tempTable2..I need to update 'String_To_Use' column so it would contain: 0000-1020, 1199-1210, 1260, 1299. #tempTable1 can help to build the logic
replace dsBranchPlant with name of your data set that your using to supply data parameter. And "All" condition is if all params are choosen instead of showing each one. Game this up as an expression and see where you stand.
iif(Parameters!BranchPlant.Count = CountRows("dsBranchPlant"),"ALL",Join(Parameters!BranchPlant.Label,","))

Printing records with condition Crystal reports

I am using stored procedure in mssql as backend, vb.net as frontend (just info).
There are a lot of records in the database and I am printing in crystal reports.
Now I want to filter the records from crystal report and not by adding a new parameter to procedure or changing database structure or else.
For now,Say there are columns : Name , Amount.
I want to put filter in amount like only display records whose amount above 100 or something. So other records with less than 100 should not be displayed.
This filter will be passed by the user so it'll be random.
I can't find a proper answer on internet. Might be a duplicate question, if so please post the link of the question if it is duplicated.!
Thanx anyways...!
In general the idea is to:
Create the parameter (user choose what will be the input/value) - link
Set filters, what values should be displayed in regards to parameter - link
On right side there is a DataExplorer window, where You need to add a Parameter (define his name, what question will be shown to user and what type the param will be / what values can be set inside).
Once done, You can jump to Data tab of a report, click Interactive Filter and specify which column must fit what condition with what value = Parameter (that one user will enter in Report).
Example: I will create AmountParam, with message "What should be the minimum amount?". Type will be set to Integer. Going to Report->Data->Interactive Filter, choose Amount as a Column, AmountParam as a Parameter and set condition Greater then (>).

SSRS: Passing/Setting parameter to Dataset using Expression

I am using Microsoft SQL Server Report Builder 3.0. I have created a Stored Procedure (stored_procedure1) in the database which has a Parameter (parameter1). Here, stored_procedure1 returns result1.
Then, I used stored_procedure1 to create a Dataset (dataset1) in the Microsoft SQL Report Builder 3.0. Next, I created a Table (table1) in Microsoft SQL Report Builder 3.0 with 2 rows and 2 columns (total 4 cells).
I would like to fill each element of table1 with result1 from dataset1. Hence, I set expression of each cell of table1 as follows:
=Sum(Fields!result1.Value, "dataset1")
When I run this report, it works perfectly and asks me to enter parameter1. However, I want to use single Dataset (dataset1) with different values of parameter1 for each cell of the table. Hence, I want to pass/set parameter1 with unique parameter_value for each expression of table cells. Say I want to set parameter1 = parameter_value1 for first cell.
For example, if I need to set parameter_value = 5, I did something like
=Sum(Fields!result1.Value, "dataset1"), Parameters!parameter1.Value = 5
I also tried following:
=Sum(Fields!result1.Value, "dataset1") & Parameters!parameter1.Value = 5.
It doesn't work.
In summary, I coudln't pass or set parameter value together with an expression.
Can we set/parameter value.
I would like to thank you in advance.
If anyone got stuck with this problem, I found a way around for this. T
here is no way one can pass parameter within expression.
You will need to create a subreport to do this. You can pass parameter to subreport.
Its little time consuming. However, it seems there is no other way around.

Hide Columns Based on parameter value not working in SSRS

I have a SSRS report which have N number of Columns. I need to hide Certain columns based on a parameter "jobcode" . I have tried below expression in Column Visibility Pane,
=iif(Parameters!JobCode.Value=1,"False","True")
While Executing the report I got below Error,
"The Hidden Expression used in the tablix 'Tablix1' returned a
datatype that is not valid"
I have tried like below,
=iif(Parameters!JobCode.Value=1,0,1)
But, got the same error. Can Anyone help me to find out answers for below queries
How to achieve the above requirement in ssrs?
If I need hide column based on multiple parameter values, say 0 and 1, How to do it?
Thanks for the help.
If JobCode = 0 , Show
=IIF(CInt(Fields!JobCode.Value) = 0,true,false)
Try this.
Follow these steps:
Right click in your column>Column Visibility>Show or hide based on an expression
Expression, use that:
=Parameters!parameter_name.Value<>1

UNION multiple datasets in SSRS outside query

I have two data sets with exactly the same fields that I would like to combine into one dataset.
I cannot put a UNION/JOIN and make it return one dataset in the query as all data is encrypted and gets decrypted by an assembly reference loaded in SSRS (so I cannot run the necessary WHERE's unless I use a filter once the data is in SSRS).
I can return the second dataset using Lookup/LookupSet however I am using this data in a bar chart so (somehow) need both sets of data to display on it. If I was using a tablix I would be able to "hack" it by putting a second tablix without headers underneath the main tablix and show it like that. Unfortunately being a graph I cannot do this.
I also tried running it as one dataset, returning all values and then running "filters" based on category groups in the chart however for whatever reason [bug in SSRS?] the filter on these filters the whole result set, not just the one category group.
Is what I am trying to do possible in SSRS? Seems so basic but after a week of trying I have just about given up!
Merging two datasets is not possible but there may be a way to fake it for your chart purposes by doing a SUM of LookUpSet. What ever field is used as your value needs to be looked up using whatever criteria is being used for your axis.
Let's say you're displaying sales by month. Your value field is SUM(Fields!TotalSales.value) and your date field is Fields!month.value. You'd want to add the value from dataset1 and lookup the total from dataset2 - like:
=Fields!TotalSales.value + Code.SumLookup( LookupSet(Fields!month.Value, Fields!month.Value, Fields!TotalSales.value, "Dataset2") )
Unfortunately, SSRS doesn't let you sum a lookupset (so what's the point of it?), so you have to use custom code to do it.
Function SumLookup(ByVal items As Object()) As Decimal
If items Is Nothing Then
Return Nothing
End If
Dim suma As Decimal = New Decimal()
suma = 0
For Each item As Object In items
suma += Convert.ToDecimal(item)
Next
Return suma
End Function
Stolen from: How to combine aggregates within a group with aggregates across groups within SSRS
You're data is obviously different but the concept should be the same.

Resources