Formatting Parameters in SSRS Report - reporting-services

I have an SSRS report that takes 2 optional text parameters as below:
StartDate, Text, allow Null, format YYYYMMDD
EndDate, Text, allow Null. format YYYYMMDD
I am trying to format a header text box that will show the below:
If the parameters are Null, then I would get by default the Month Name and the Year (as the report will get data defaulted to the previous Month)
If the parameters are set then I want to format them as dd MMMM YYYY (so 20141103 will be formatted as 03 November 2014
Here is the code I am trying to use for the Expression in the text field:
= IIF(IsNothing(Parameters!StartDate.Value),
" for " & MonthName(Month(DateAdd("m",-1,Today))) & " " & Year(DateAdd("m",-1,Today)),
"From " &
RIGHT(Parameters!StartDate.Value,2) + " " +
MonthName(Month(
LEFT(Parameters!EndDate.Value,4) + "-" +
MID(Parameters!EndDate.Value,5,2) + "-" +
RIGHT(Parameters!EndDate.Value,2)
)) + " "
+ LEFT(Parameters!StartDate.Value,4) +
" to " +
RIGHT(Parameters!EndDate.Value,2) + " "
+ MonthName(Month(
LEFT(Parameters!EndDate.Value,4) + "-" +
MID(Parameters!EndDate.Value,5,2) + "-" +
RIGHT(Parameters!EndDate.Value,2)
)) + " " +
LEFT(Parameters!EndDate.Value,4))
so as you can see, if the parameter is Null (allowing for the report to default to run the last months data when scheduled) then the function should just show something like December 2014 but if they are entered as YYYMMDD then I need to format them.
I am getting the below error (in SSRS in Visual Studio 2013):
[rsRuntimeErrorInExpression] The Value expression
for the textrun ‘Textbox15.Paragraphs[0].TextRuns[0]’
contains an error: Conversion from string "--" to type 'Date' is not valid.
I have also tried using CDate around
LEFT(Parameters!EndDate.Value,4) + "-" +
MID(Parameters!EndDate.Value,5,2) + "-" +
RIGHT(Parameters!EndDate.Value,2)
(these should come out as 2014-11-01 for example) but again, no luck
So where am I going wrong here and how can I format those dates if they are entered?

I would use expression something like this:
=Format(CDate(Left(20150131, 4) + "-" + Mid(20150131, 5, 2) + "-" + Right(20150131, 2)), "dd MMMM yyyy")
I believe it is better to use integer or date parameters rather than text parameters. So you could convert date text parameter to date before it appears in the report by doing something like:
select cast('20150131' as date)

Related

SSRS Hyperlink dual parameters errors

I am trying to pass a hyperlink in SSRS to open a new SSRS report (in pdf) from a text box. It is currently set up and works passing a single parameter :
="http://servername/ReportServer_REPORTS16/Pages/ReportViewer.aspx?%2fdummy%2fDocuments%2fCertificate+of+Insurance+Issued&rs:Command=Render&PolicyNo="
& Parameters!PolicyNo.Value &"&rs:Format=PDF"
However when I add in the second parameter :
="http://servername/ReportServer_REPORTS16/Pages/ReportViewer.aspx?%2fdummy%2fDocuments%2fCertificate+of+Insurance+Issued&rs:Command=Render&PolicyNo="
& Parameters!PolicyNo.Value &"&
Entitled="&Parameters!Entitled.Value &"&rs:Format=PDF"
I get an error message :
The ActionInfo.Action.Hyperlink expression for the text box
‘Textbox48’ contains an error: [BC30277] Type character '&' does not
match declared data type 'Object'.
I've gone through every similar error I've found on google but cant work out where im going wrong.
You need to convert all your values to strings then use the + operator....
Here'a an exmaple from one of my reports that does the same thing.
=IIF(Fields!PackSizeDesc.Value = Nothing, Nothing,
"http://MyServername/ReportServer?/Brand+Value/_sub+SKU+Price+Details"
+ "&CountryID=" + cStr(Fields!CountryID.Value)
+ "&CategoryID=" + cStr(Fields!CategoryID.Value)
+ "&RecordedPeriodID=" + cStr(Parameters!PeriodID.Value)
+ "&TMB=" + cStr(Fields!TrademarkBrandID.Value)
+ "&PriceStage=" + cStr(IIF(Fields!IsActualprice.Value = 1, 10, 11))
+ "&pm=" + cStr(Fields!PackMaterialID.Value)
+ "&pt=" + cStr(Fields!PackTypeID.Value)
+ "&ps=" + cStr(Fields!PackSizeID.Value)
+ "&psu=" + cStr(Fields!PackSizeUnitID.Value)
+ "&upp=" + cStr(Fields!UnitsPerPack.Value)
+ "&rc:Parameters=Collapsed")
Note: The first line just disables the link if there is now value in a particular column. This does not render to PDF but that's not part of your issue.

Line breaks in SSRS report

I have an address Field in my SSRS report that displays as below
PARADISE BALTI
104
WHITWORTH ROAD
ROCHDALE
LANCASHIRE
OL12 0JJ
How do I format this so it all appears on one line?
For this you have to write expression and concatenate string like
=First(Fields!Name.Value, "DataSet") + "<br/>" + First(Fields!Address1.Value, "DataSet") + "<br/>" + First(Fields!City.Value, "DataSet") + ", " + First(Fields!State.Value, "DataSet") + " " + First(Fields!Zip.Value, "DataSet")
Take a text box and create a placeholder and set value as an expression shown above.. Then choose markerup type as HTML ...

format lookupset expression

In Report Builder, I have an expression using the lookupset function that pulls back either nothing, a date and description, or several dates and several descriptions. The data it is pulling is correct. I have searched this forum and MSDN. Using what I've found in both places, I have tweaked my expression to the following.
My expression:
=Join(Lookupset(Fields!ProjectName.Value,
Fields!ProjectNames.Value,
Fields!TaskBaseline0FinishDate.Value & " - " & Fields!TaskName.Value,
"DsActivitiesCompleted"))
However, when this is displayed it doesn't have a carriage return, it just puts one after another after another. Example Below:
08/05/2015 – Milestone: Kickoff meeting Complete 08/18/2015 – Milestone: PMT Test Planning Complete 08/26/2015 – Milestone: Set CCD Date 08/26/2015 – Sprint 0 Complete 09/18/2015 – Milestone: Wave 1 Complete 09/28/2015 - Milestone: Wave 2 Complete
What I want it to look like is below. If possible I would like to have bullet points in front of each line as well.
My question is how do I get it in the format above?
Thanks,
MM
You have missed the final (optional) argument of JOIN which states which character you want to use to join your string together. Changing your expression tyo use vbCrLf (the VB new line code) as follows
=Join(Lookupset(Fields!ProjectName.Value,
Fields!ProjectNames.Value,
Fields!TaskBaseline0FinishDate.Value & " - " & Fields!TaskName.Value,
"DsActivitiesCompleted"),
vbCrLf)
Gives this output
Update
Use the below to use Chr(183) as a bullet character for each new line as well
=" " + Chr(183) + " " +
Join(Lookupset(Fields!ProjectName.Value,
Fields!ProjectNames.Value,
Fields!TaskBaseline0FinishDate.Value & " - " & Fields!TaskName.Value,
"DsActivitiesCompleted"),
vbCrLf + " " + Chr(183) + " ")

AS3: Date Object Not Returning Month Correctly

Anyone else having this issue while trying to name a file with the current date and time.
redeemedImgName:String = "soemtext_" + datToday.getFullYear() + "-" + datToday.getMonth() + "-" + datToday.getDay() + "-" + datToday.getHours() + "-" + datToday.getMinutes() + "-" + datToday.getSeconds();
Today is 4/2/2015, but I got the following file name:
"sometext_2015-3-4-15-32-10.jpg"
Yesterday, I was receiving 3/32/2015. Again, anyone else experiencing this issue?
Please advise,
rikixass
datToday.getDay() returns an integer 0-7 corresponding to the day of the week. What you are looking for is datToday.getDate(), which returns the actual calendar number of the day. The months are zero based, so you'd get 3 for April, 4 for may etc.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Date.html

SSRS report formatting for excel

I am writing an SSRS report in which my client wants the report header to contain the criteria on which the report is based (actually, this is the report variables, such as date).
I tried to do this with textboxes, but can't seem to position the textboxes in such a way that upon export to excel there aren't crazy cell merges.
I also tried to do this with a table in the report body, but got the variable added to each line of the report.
I don't see a position property, as if I was working in just a web form, but am at a loss as to what to do. Any suggestions? Thanks!
Cell merges are a fact of life when exporting to Excel unfortunately, that's how the report rendering engine tries to maintain fidelity with the original report design. The best way to minimise this is to ensure the edges of the report elements align with each other as much as possible, so that the renderer can align the report without having to merge cells.
What you are doing by putting textboxes in the report header to display the value of selected report parameters is a good approach that is commonly used, so keep experimenting with the layout to get it to align correctly.
If you can describe what is happening when you export the report in a bit more detail I might be able to offer some more advice.
In my reports, I add an additional table at the end of the report and assign a page break before the tablix. In the large, single-cell table, I write sentences using quoted text, built-in fields, and parameter values to list all of the parameter information. I label the Name of the Tablix "Parameters" so when the report is downloaded, all of the parameter data goes with it in a nice, non-invasive format. When troubleshooting reports this has proved very valuable.
Here's an example:
=Globals!ReportName + " run by " + User!UserID + " on " + FormatDateTime(Globals!ExecutionTime, DateFormat.ShortDate) + ". "
+ vbcrlf +
"Parameters: " + "Program ("+Parameters!BusinessEntityID.Label+ "), Deliverable Status Code (" + Join(Parameters!DeliverableStatusCode.Label, ", ") +
"), Science Area (" + Parameters!ScienceAreaID.Label + "), Thrust Area (" + Parameters!ThrustAreaID.Label + "), Center (" + Parameters!CenterID.Label + ") "
+ IIF(Parameters!TaskActiveFrom.Value is Nothing, "", ", Tasks Active between "+ FormatDateTime(Parameters!TaskActiveFrom.Label, DateFormat.ShortDate)
+ " and " + FormatDateTime(Parameters!TaskActiveTo.Label, DateFormat.ShortDate))
+IIF(Parameters!TaskStartFrom.Value is Nothing, "", ", Tasks Started between " + FormatDateTime(Parameters!TaskStartFrom.Label, DateFormat.ShortDate)
+ " and " + FormatDateTime(Parameters!TaskStartTo.Label, Dateformat.ShortDate))
+ IIF(Parameters!DeliverablePlannedFrom.Value is NOTHING, "", ", Deliverable Due Date between " + FormatDateTime(Parameters!DeliverablePlannedFrom.Label, Dateformat.ShortDate)
+ " and " + FormatDateTime(Parameters!DeliverablePlannedTo.Label, Dateformat.ShortDate))
+ IIF(Parameters!DeliverableExtendedFrom.Value is Nothing, "", ", Deliverable Revised Due Date between " + FormatDateTime(Parameters!DeliverableExtendedFrom.Label, Dateformat.ShortDate)
+ " and " + FormatDateTime(Parameters!DeliverableExtendedTo.Label, Dateformat.ShortDate))
+ IIF(Parameters!PublicationReceivedDateFrom.Value is NOTHING, "", ", Publication Received Date between " + FormatDateTime(Parameters!PublicationReceivedDateFrom.Label, Dateformat.ShortDate)
+ " and " + FormatDateTime(Parameters!PublicationReceivedDateFrom.Label, Dateformat.ShortDate))