I have a report that holds two tables, one is for a Detail report and the other a Summary report. I've set it where if the Summary parameter (a boolean) is set to true then you only see the Summary table and vice versa if it's set to false. But I have a text box in the header that reads Report (Detail). I would like this text box to change depending on the same parameter, so if the summary parameter is set to "true" then the textbox will read Report (Summary) and if set to false it will read Report (Detail). How can I write this expression, I've searched but found nothing other than mentions of IIF expressions but I'm new to SSRS and don't know how to write these off the top of my head yet. Sorry if it has been answered I just couldn't find it.
This is how I have the expression for my Details visibility table to show if the Summary parameter is false (I found this out online too):
=IIF(Parameters!IsSummary.Value = 1, True,False)
I believe you get rep for selecting an answer (I also gave your question an upvote)
=IIF(Parameters!IsSummary.Value = 1, "Report (Summary)", "Report (Detail)")
The basic structure of the Iif is:
Iif(<equality>,<do this when true>, <do this when not true>)
this is more compact
beacuse if is boolean, you don't need the equivalence.
=IIF(Parameters!IsSummary.Value, "Report (Summary)", "Report (Detail)")
Related
How can I tell if a subreport is empty? Is there a property or function I can use to check whether there is any data in the subreport? I want to write a subroutine that says
If IsEmpty(subreport) Then
subreport.Visible = False
Else
subreport.Visible = True
End If
That, combined with making the subreport small and allowing CanGrow would help me display only the values that do exist without taking up space on my report if the subreport is empty. Ideally, I'd also be able to hide the label of the subreport if it's empty.
If the VBA code is going to be on the main report then you would use,
Me.subreport.Report.RecordsetClone.RecordCount
to get the number of records. If the code is in the sub-report then you only have to write,
Me.RecordsetClone.RecordCount
If you have any issues with this or need an explanation leave a comment and I'll get back to you.
I'm having problem with my access report. I'm sorry if it looks trivial, but I'm quite new here...
I want a control to change it's source when it is empty. To exemplify (with a stripped down version of the problem), my report is based on a query which show the fields "id", "name" and "instution". If the "name" field is blank (empty), then "institution" is not.
I want a control in each row in the report to show "name" if it's not empty, and "institution" if "name" is empty.
I basically want a control to display a different information based on the value a field in my recordsource. But for each row.
I tried to use the "on current" event to set the controlsource or the value, but it won't really work, since anytime I click on a specific record, it change the value of for all record.
I basically understand the report to be continuous forms, and found some similar issues, but the solutions didn't work for my case.
I thank you a lot for an answer, let me know if you need more info! Any help is appreciated.
Use a query and IIf.
SELECT Id, IIf(Trim([Name] & "") = "", [Institution], [Name]) FROM ATable
Base the report on the query.
IIf: http://office.microsoft.com/en-ie/access-help/iif-function-HA001228853.aspx
I am working on a SSRS Report.
In the report , i need do display a field of type: boolean that is either true or false.
When I try to display it on the report , it's showing as true/false.
But, I would like to represent it as yes if value is true and no if false.
I think one way of doing is by changing the query that gets data to report.
But I would like to know, is there any way we can write that condition in the report itself
to change representation.
You can use an expression field, add a textbox, right click => expression and use something like this: =IIF(Fields!LineTotal.Value = True, "This is true", "This is False")
Thank you in advance for taking your time to answer my question.
I am having trouble with expressions in the SSRS reporting system.
The Field I am adding required fields from the dataset I provided in the report, however when I try to preview the report I get the Following message:
"A Value expression used for the report parameter ‘Policies_Total’
refers to a field. Fields cannot be used in report parameter
expressions."
This is my expression:
=IIF(Sum(Fields!policy_id.Value, "DataSet1") Is Null, 0, Count(Sum(Fields!policy_id.Value, "DataSet1")))
That was suppoed to be converted from Crystal reports which has the following expression:
If IsNull ({usp_rep_agent_cases;1.policy_id}) then
0
Else
Count ({usp_rep_agent_cases;1.policy_id})
Any help is much appreciated.
Thank you
I think it may be as simple as understand that a 'parameter' should be passed into SSRS before fields are created for the most part. If this parameter is DEPENDENT on the value of something else first being chosen you cannot list it first as the field is not yet populated to my knowledge. It appears you are trying to use an expression to count something from a field from a dataset when you just make a dataset and reference that field directly. So instead of trying an expression you may choose a few other options instead:
Choose on the left pane of your parameter 'Available Values' selected 'Get values from a query'. You may use your query which is a 'dataset', value is self explanatory, label is what the end user will see display.
The option 'Allow null' value will accept a null value
You may run into situations where multiple datasets may need to be used, multiple selects or querying objects. In my experience with SSRS it gets mad at times when you try to reference a dataset used to display data with a dataset used to determine an event or action. SSRS also gets relativity slower the more Expressions you do so doing a whole report with nothing but expressions versus taking the power of the built ins of the RDL language is not really worth it IMHO.
For SSRS expressions you need to use IsNothing for NULL checking, something like:
=IIF(
IsNothing(Sum(Fields!policy_id.Value, "DataSet1"))
, 0
, Count(Sum(Fields!policy_id.Value, "DataSet1"))
)
In fact the whole expression seems a bit odd; what are you specifically trying to achieve with your expression? Are you just trying to count non-null values?
=Sum(IIf(IsNothing(Fields!policy_id.Value), 1, 0), "DataSet1")
Also, your error seems to be saying that a parameter is referencing a field when this isn't allowed, which may not be solved by changing syntax; I think more information about what you're trying to achieve is required here.
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!