The value expression for the textbox4 refers directly to the field - reporting-services

I have mult dataset and i used expression and set the dataset as well but getting error
" The value expression for the textbox4 refers directly to the field dataex without specifying a dataset aggregate. when the report contains multiple datasets"
= Mid((Fields!Dateex.Value,3,2) + "-" + Left(Fields!Dateex.Value,2) + "-" + Right(Fields!Dateex.Value, 4),"Gas")

Your dataset "Gas" can contain 1 or more records. If you have a textbox that is not inside a tablix or other bound control then you need to tell SSRS how to deal with more than one record.
So, you need to do one of the following depending on your situation.
If textbox4 is in a table/tablix/matrix etc, you need to set the dataset property of the table/tablix/matrix to Gas, you can then remove the "Gas" part from your expression
If textbox4 is NOT part of a table/tablix/matrix etc, AND "Gas" only ever contains 1 record then you can change all your references from Fields!Dateex.Value to FIRST(Fields!Dateex.Value)
If textbox4 is NOT part of a table/tablix/matrix etc, AND "Gas" contains more than one record then you will have to decide how you can identify the record you need, this might mean using a lookup etc. If you get to this point, edit your question and show some sample data and you report design, without this it's difficult to help you.

Related

SSRS lookup missing dataset

I have a dataset which looks like this
Name Spend
"First Aid" 2
"Healing Arts" 0
"Surgeon" NULL
I then have three separate textboxes which will be filled with the value of the column which matches the name.
Example: show value of spend in textbox if value of name equals First Aid
for this I've made following expression
=Lookup(Fields!skill_name.Value, "First Aid", Fields!skill_spend.Value, "Skills")
My problem is however that I get an error saying that skill_name is missing its dataset, which doesn't make sense to me as it is informed in the end of the expression (skills)
I think you may be misunderstanding the purpose of Lookup and how it is used. The purpose of the Lookup function is akin to a JOIN in SQL in some ways. Basically, you would have two datasets that each have a matching field with the other. In that scenario, the expression would match on the skill_name field and lookup the skill_spend value and the expression would look something like the following.
=Lookup(Fields!skill_name.Value, Fields!skill_name.Value, Fields!skill_spend.Value, "Skills")
As the documentation shows, the first reference to skill_name is the field you are referencing from the current dataset. The second reference is to the dataset from which you are attempting to look up a value. The third expression is the field you are looking up and the dataset should be the one you are attempting to look up a value from, not the current dataset scope.
Lookup(source_expression, destination_expression, result_expression, dataset)
From the best I can tell, you have a single dataset but separate textboxes that need the correct spend value. I think the following expression will work.
= IIF(Fields!skill_name.Value = "First Aid", Fields!skill_spend.Value, Nothing)
This expression should get the skill_spend value associated with the row "First Aid" only and leave the textbox blank otherwise.

Display Parameter in SSRS Report

When a user runs the report, they can select a multi-value parameter. I know I can use Parameters!Value.Label(0), Parameters!Value.Label(1), etc to display the each of the values based on their location within the array, but the number of the values changes based on how many values the user selects.
The report separates each value onto a separate page. I'm looking to (a) have an expression that identifies which value's info is displayed on the page, and (b) an expression that labels the tab as the value when the report is exported to Excel. I expect the same expression would work for both.
I believe I should be using Array.IndexOf(Split(Parameters!Value.Label.ToString(), ","), Parameters!Client.Label), but just get #Error as the output when the report renders. I'm not sure, but it seems like the Array... expression would only identify the location within the array.
Could someone offer some insight into where the syntax is wrong? I'm not sure if the issue is syntax or it's an issue of how to specify which dataset to use in the expression.
Thanks.
This is what you should use
=Join(Parameters!CSR.Label, ", ")

MS Access, Use Expression Builder to Compare Field in One Table to DLookup in Another Table

I'm trying to make a MS Access report, where I use a text box to display a field value, then have another text box indicating if the first value is higher or lower than an entry in a separate table.
The report has a record source of "Table 1", and a textbox named "txt_Value1" which displays the number in Field: "Value1". I have a second table, "Customer_Criteria" which has a field "PassValue" that I want to compare against. My expression builder statement is:
IIf([txt_Value1]<(DLookUp("[PassValue]","[Customer_Criteria]","[Customer] = 'ABC'")),"TRUE","FALSE")
This statement always returns false, regardless of what the correct logical result is.
I've tested it, writing:
IIf(1<(DLookUp("[PassValue]","[Customer_Criteria]","[Customer] = 'ABC'")),"TRUE","FALSE")
And I get the correct results. Also, if I write:
IIf([txt_Value1]< 1,"TRUE","FALSE")
I get the correct results. What am I missing to compare the textbox value vs. the Dlookup?
As I understand, both fields are numeric. Access may consider those fields as text, so for correct comparing use type conversion.
Try this:
IIf(CLng(Nz([txt_Value1],0))< _
CLng(Nz(DLookUp("[PassValue]","[Customer_Criteria]","[Customer] = 'ABC'"),0)), _
"TRUE","FALSE")
Nz required if fields may contain NULL values, in this case type conversion function will return error.

SSRS - possible to share the same filter definition for a chart and a tablix?

In Excel you have the option of showing a table below your chart that shows the data used in the chart - I am trying to replicate that behavior in SSRS.
Scenario:
I have one dataset from which I want to populate two (Chart + Table) elements (so two charts and two tables). Each Chart + Table combo needs to use the exact same filter, but I don't want to manually define that exact same filter on each object (if I need to change it, I don't want to have to make the change on two entities).
Yes I know there are other ways to accomplish the same end result, such as perform the filter in the SQL, or to instead define two separate datasets, and then apply the filter on the dataset itself (so it will then cascade down to both the Chart and Table).....or in other words, I'm not asking if this is a good idea, I'm asking if it is possible. :)
Closest thing I can think of to what you want is to define the logic of your filter in custom code, and call the custom code in your two filters.
If the logic ever changes, you would only have to change it in one place.
But it's not possible to define the filter on your tablix, for instance, and then in your chart put in some kind of "use the same filter as my tablix" command.
I would add a Calculated Field that checks your criteria and gives a 1 or 0 depending on whether it meets all the criteria or not.
Field Name: MeetCriteria
=IIF(Fields!AGE.Value < 10 and Fields!status.Value = "PAID", 1, 0)
Then you just need to filter on the new calculated column:
Expression: Fields!MeetCriteria.Value
Type: INTEGER
Operator: =
Value: 1
Not quite what you want but much easier than duplicating the criteria everywhere.
For a multi-value Status parameter, you could do something like:
=IIF(Fields!AGE.Value < 10
AND INSTR("|" & Join(Parameters!Status.Value, "|") & "|", "|" & Fields!Status.Value & "|") > 0,
1, 0)

SSRS: Can I know if user selected "ALL" in multivalued param?

Customer wants me to repeat the parameter values in the page header of the report. But if they just choose "Select All" on a multi-valued parameter, they want the text "Any" listed.
For example, one parameter has a fixed set of 9 values. I hard-coded the expression for a text box to:
="Room Size: " &
iif(Parameters!pRoomCap.Count=9,
"Any",
Join(Parameters!pRoomCap.Value, ", "))
How can I do this if the parameter source is a query of unknown size?
Try this out. You need to compare the total number of parameters in the dataset to the count of selected parameters. The following assumes that your multivalue parameter is using a dataset called "dsRoomSizes"
="Room Size: "
& iif(Parameters!pRoomCap.Count = count(Fields!pRoomCap.Value,"dsRoomSizes"),
"Any",
Join(Parameters!pRoomCap.Value, ", "))
This expression will work in the page header/footer.
UPDATE
In the interests of finding a solution to your problem, the following should work for you. It feels hackish and I encourage you to keep research alternative methods but this will work:
Create a second multivalue parameter and name it something like "pRoomCap_hidden".
The source of the parameter is the exact same query
In the parameter properties, setting the default values to the same query
Important: Set the parameter visibility to hidden
This will create a second multivalue parameter in your report that is exactly the same as your initial multivalue parameter only this parameter list will have all values selected by default.
Enter the following expression in a textbox in your header:
=IIF(Parameters!pRoomCap.Count = Parameters!pRoomCap_hidden.Count,"All",Join(Parameters!ReportParameter1.Value,", "))
The above will compare the selected values in each parameter list. If the lists contain the same selected values then that indicates that "All" have been selected in the first list.
Like I said, it is hackish but it definitely works. Until you are upgraded to 2008, this might not be a bad workaround for you.
Can you compare the count of the parameter to the count of the dataset you pull the parameter values from?
I unioned my dataset for the parameters with one which I created manually with a "select" statement - I was then able to force the value to be something like -1 or null.
Then simply check if the parameter contains -1 or null and replace the value in the header with the replacement text.
BTW- I am now using SSRS 2008 R2 and this solution worked for me. My report uses three datasets; but only one in the tabilx that I needed to hide a row in. After long hours of searching and many, many, many unhelpful for wrong answers; the solution of creating a identical parameter only hidden (I marked it as internal) and then comparing to the exposed one is brilliant and easy.
Thank you very much!