Reporting Services column visibility expression includes substring column names - reporting-services

I have an SSRS 2012 report with columns that are to displayed or hidden based on user parameter selections. Each column has a visibility expression associated with it. For instance, the expression to show or hide the "Cash Flow" column is:
=IIF(InStr(JOIN(Parameters!IF_Variables.Value,","),"CashFlow")>0,False,True)
The problem is that I also have a column called "AnnualCashFlow", with a corresponding visibility expression. If the users selects it, the "CashFlow" column will also be displayed, even if it wasn't chosen, because it is a substring of the longer column name.
There are several other columns that are related in this way. How can I formulate an expression that will only find the exact string requested?

You can use the delimiter to help with this:
=IIF(InStr("," & JOIN(Parameters!IF_Variables.Value, ",") & ",", ",CashFlow,") >0
,False
,True)
Since this includes the delimiters in the check, this will match CashFlow only, and not when it's part of a longer string.
Say you have the CashFlow column and your parameter list is Col1,Col2,AnnualCashFlow. In the expression we are looking for ,CashFlow, in the adjusted string ,Col1,Col2,AnnualCashFlow, there is no match so the Hidden expression is working as required.

Related

SSRS - Referring to a table Expression within a Text Box Expression

Good morning,
I have the below expression in a table column within SSRS (Essentially outputs a Yes/No based on whether another column has a value.
I want to refer to this expression within a header row that counts the number of Yes answers. However I do not know how to refer to the table expression within that header expression.
I have tried !Fields (this won't work as it is a lookup based on multiple datasets) and !ReportItems but it cannot use this as the original expression is an aggregate.
Thank you for any help you can provide.
The table expression:
=IIF(NOT ISNothing(Lookup(Fields!UserID.Value, Fields!USER_ID.Value, Fields!Logins.value,"CE_LoginsList")), "Y", "N")
What I would expect the headers expression to resemble:
=Count(IIF(ReportItems!HasLicense.Value, "Y", Nothing))

In SSRS, how to include first row from different dataset in tablix?

I am creating a report, the purpose of which is to print a letter to many different people. Obviously each person's name, email, etc. will be different. For this I am using a list, which I understand uses a tablix.
Now inside each letter I also need some global data that comes from a dataset. For example, the company email, telephone number, etc. This data will be the same for every letter. However, every time I try to use some expression to get this, I get an error such as:
The Value expression for the text box ‘Textbox11’ refers to the
field ‘URL’. Report item expressions can only refer to fields within
the current dataset scope or, if inside an aggregate, the specified
dataset scope. Letters in the names of fields must use the correct
case.
The expression I'm using to get the above error is
=LookupSet(true, true, Fields!URL, "SystemVars")
I've tried other things but I can't figure out what I need to make it word.
Is there an expression I can use to solve this problem? If not, what steps should I take to get my letters working?
You are missing the ".Value" portion in the expression. Try this:
=First(Fields!URL.Value, "SystemVars")

SSRS report with muliple datasets

I have added a separate dataset to an SSRS report...it contains some similar tables as another dataset. When I go to write expressions the fields in my new dataset have a "SUM" in front of the field numeric fields and "First" in front of the char fields??? Now I can't pick the numeric field for my report because it will "SUM" up all the data
Just remove the SUM() portion once you add the field. Perhaps it is there because of the scope of the bound item. There is no harm in removing the aggregate if the field is in a position in which a detail can print SUM(X)=X.
To follow on the heels of Ross' answer...
You can remove those [SUM(FIELD)] tags from your table by clicking it and hitting delete. To add the single data value you want to display, type the field name in brackets like [FIELD] right into that text box.
Alternately, edit the expression the be:
=Fields!YOURFIELDNAME.Value

SSRS. Hide a Column based on Row Group Value

My application uses SSRS to produce payslips for employees. The Payslip report consists of a tablix with 5 columns. Among the 5, is a column called "Units" and another called "Invoice value".
The report has several Row Grouping levels, but the only important one for this question is the Payslip Number Row Grouping "RG_SlipNum". There is a page break after each "RG_SlipNum" RowGroup.
When users want to print Payslips, they can optionally supply up to 5 parameters which filter the result set to print out.
Employees can be paid based on the number of units delivered * a rate (Unit Based), or by a percentage of the invoice value (Invoice based) for the delivery (Oversimplified, but hopefully, you get my drift).
If the employee is Unit based I want the Units Column to Show, and the "Invoice Value" Column to be hidden. If they are Invoice based I want both columns to show.
My dataset has a bit field indicating whether to show or hide a column based on the logic above. It will be a 1 or a 0 for every underlying row within the current rowGroup. I have tried to use the First(,) function in a Column Visibility expression on the "Invoice Value" Column. However, I get the following error whenever I try to limit the scope of the First Function to the current Payslip Rowgroup using the RowGroup name.
"The Hidden expression for the tablix 'X' has a scope parameter that is not valid for an aggregate function. The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing data region, or the name of a dataset. "
So, my Question(s)
Can you define a RowGroup name as the Scope argument in a First() function?
If not, What's the best way of achieving this without completely re-working my Dataset / RDL to accomplish this. (Using SSRS2008)
Why is it always just after posting a forum question, you figure it (or some workaround) out?
I'd still like some (better) answers if anyone sees this, but I've set a cell in the tablix to the value of the bit field that determines whether to show the column or not. I then changed my Column Visibility expression to check the cell value (using ReportItems!textboxname.Value) and it's working. as I scroll the payslips the columns visibility changes appropriately.

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!