string format with JOIN inside SSRS expression - reporting-services

I am using an SSRS expression to format the result of a string like this based on a condition
= IIf(my_condition,"All active items",JOIN (Parameters!SelectedBooks.label,"<br/>"))
This will make the resultant string comes on next lines automatically if my condition is false and is working fine . Instead of
<br/>
i would like to use li tags
<li>Parameters!SelectedBooks.label</li>
If li is used my items will comes better in HTML view. So how can i use a string format or use 3 sections with JOIN of SSRS expressions

I think that this expression should get you what you need.
="<li>" & Join(Parameters!SelectedBooks.Label, "</li><li>") & "</li>"
No need to get too crazy with Format and Join, I think simple string concatenation and Join should do the trick.
Result in preview mode:
This will display the raw HTML used in a TextBox and in preview mode, so I don't know what the value is. That part I leave up to you.
Hope this helps.

Related

SSDT using multiple input fields in expression to create hyperlink

I am building an expression for a hyperlink in SSDT but I am trying to build it with 2 field inputs.
Here is what I started with in the expression box and it works.
="http://s1324.com/Report&Car=Toyota&Model=Celica"
Then i substituted Celica for &Fields!Model.Value and that URL worked. (where Fields!Model.Value = Celica)
="http://s1324.com/Report&Car=Toyota&Model="&Fields!Model.Value
Now i am trying to also substitute the word Toyota for a Car value (where Fields!Car.Value = Toyota) but i cant seem to complete the entire correct url
="http://s1324.com/Report&Car="&Fields!Car.Value"&Model="&Fields!Model.Value
Is there a way to use 2 inputs to create a URL?
Thanks
You've missed the ampersands in the middle part. Try this
="http://s1324.com/Report&Car=" & Fields!Car.Value & "&Model=" & Fields!Model.Value
If you put spaces between operators it's easier to read

SSRS Font Color Using Wildcard parameter

Hi I have a report that i used a wild card search parameter so that i can pull record that contains a certain text.
For example: I need to search for subscription for Mary Johnson so on the keyword search box i just type "John". This set-up is working fine, but now I need to color that search keyword when found for each row. so i need assistance on expression code that mimics SQL syntax of LIKE in SSRS expression. I started to change the font color with =iif(Instr(Fields!ReportRecipients.Value)=Parameters!Keyword.Value,"Maroon","Black"), but it didnt work.
Please advise.
Sample
TOJo.eger#m.com; ruth.tuker#m.com;sandrae.espe#m.com; dan.gay#m.comIncludeReportTrueRenderFormatPDFSubjectDaily Report for IBC Medicare? was executed at #ExecutionTimeIncludeLinkFalsePriorityHIGH"
You can use some .net string functions directly in SSRS expressions. In your case you can use the Contains() function like this.
=IIF(
Fields!ReportRecipients.Value.Contains(Parameters!Keyword.Value),
"Maroon",
"Black"
)
If you are dealing with HTML and only want the search term to be highlighted then you can simply use this as the Value expression. You must leave the text box color properties as default.
=REPLACE(
Fields!ReportRecipients.Value,
Parameters!Keyword.Value,
"<span style=""color:red;"">" & Parameters!Keyword.Value & "</span>"
)
Finally, right-click the placeholder, choose properties and select Mark-up type as HTML
In this example, I used a country list and searched for the word "land", here's the results. The first column just uses the first method I described. The second column adds HTML tags.

SSRS "like" operator with nested iif

I have been trying to get a nested iif to work with the "like" operator and cannot come up with the right syntax. The basic code is shown below and before it is suggested, I have also tried this with the SWITCH operator with similar errors. The expression editor moves the error around based on the parenthesis. This particular expression is in the "fill" property of a matrix in an SSRS report. I really want to set the color on a match and leave it unchanged for no match. For the code below the expression editor shows an error on the first comma after the text "Preferred".
=iif((Fields!PHASE_TYPE.Value like "*Preferred*","ForestGreen","Blue") or
(Fields!PHASE_TYPE.Value like "*Maintain*","DarkSeaGreen","Red"))
Your syntax is not quite right for a IIF function. It takes 3 parameters, and you are only really giving it one.
You are going to need to change your expression to some like the one below.
=Switch(Fields!PHASE_TYPE.Value like "*Preferred*","ForestGreen",
Fields!PHASE_TYPE.Value like "*Maintain*","DarkSeaGreen",
True, "White") ' This last part will catch anything that does not match the above

how to solve SSRS Formatting issue?

Currently the data in field is coming like this 9646.88 and my requirement is
Remove decimal places and add comma for thousands e.g. 9,646
=IIF((RTRIM(Fields!COMPANY_NAME.Value))="VACANT","",Fields!BASE_RENT_PM.Value)
Please help, I am a newbie in SSRS.
Go to Properties pane when you select the textbox.
Then put this on Format property
#,0;(#,0)
Using Common Functions such as Text and Conversion functions shown in Expression window will give you the desired result.
For e.g,
Format(Int(9646.88), "#,###") // try "#,##0" which returns 0 if less than 1
where Int(9646.88) returns the integer portion of the number 9646 and Format(9646,"#,###") returns a string formatted according to instructions contained in a format String expression "#,###" which is a thousand seperator. Thus, it will give you "9,646".
So, in your case, try this,
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT", "", Format(Int(Fields!BASE_RENT_PM.Value),"#,###"))
Note:
Format(9646.88, "#,###") will return a rounded result 9,647 and
Format("VACANT", "#,###") returns just "#,###",
none of which may not be your desired result.
Have your Tried this?
=FORMAT(IIF((RTRIM(Fields!COMPANY_NAME.Value))="VACANT","",Fields!BASE_RENT_PM.Value),"#,###")
Should solve your issue.
Kind Regards
To add comma for thousands, you need to change your expression.
If you need output as 9,646 then try below.
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT","",Format(Convert.ToInt32(Int(Fields!BASE_RENT_PM.Value),"#,0;(#,0)")))
OR
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT","",Format(CInt(Int(Fields!BASE_RENT_PM.Value),"#,0;(#,0)")))
Updated Answer:
As you want to handle null values as well I would suggest below way to achieve your goal.
Set Textbox visibility with below expression.
=IIF(ISNOTHING(Fields!BA‌​‌​‌​SE_RENT_PM.Value),True,False)
So if null value is there then it will show blank in the ssrs report.

SSRS number format expression showing unexpected results

I have a table that contains metric data for various business units in our organization. There is one column that contains the KPI measurments. I've created a report to display each business units KPI's. Some of the metrics need to be displayed as whole numbers, others need to be displayed as percentages.
I created an expression to handle the multiple formats. The problem I'm having is with the percentages. For example one of the numbers (which should be displayed as 93.74%) appears as 939474%. If I remove the expression and set the format to percentage using the text box properties, the number displays as 93.74%.
Here is the expression I'm using:
= IIF(Fields!KPI_desc.Value like "*Rate",
Format(Fields!Value.Value,"0.00%"),"0")
Any suggestions would be appreciated.
Thank you
I guess you put this into the Format Expression so that it will return the result like integer. Actually you just need to put this expression into textbox directly.
= IIF(Fields!KPI_desc.Value like "*Rate", FormatPercent(Fields!Value.Value,2),"0")