So I have an expression that does a good job of outputting data on a report. However, I want to be able to sum/combine the fields.
Here is the original expression.
= trim(Fields!Cost_Element_User_Define_1.Value)
+ " " + FormatCurrency(Fields!Billable_Equipment.Value)
+ " " + trim(Fields!Cost_Element_User_Define_2.Value)
+ " " + FormatCurrency(Fields!Billable_Material.Value)
+ " " + trim(Fields!Cost_Element_User_Define_3.Value)
+ " " + FormatCurrency(Fields!Billable_Labor.Value)
What I would like to do is combine group/sum billable_material.value.
How would I go about doing that?
I'm using a script to send mails from a spreadsheet and like to format the date. I'm using Utilities.formatDate and this works but gives me also an error: "Method formatDate(string,string,string) not found"
var message = "<p><b>Ressort: </b>" + CurrentRow[5] + "</p>" + "<p><b>Textart: </b>" + CurrentRow[7] + "</p>" + "<p><b>Domain: </b>" + CurrentRow[6] + "</p>" + "<p><b>Thema: </b>" + CurrentRow[8] + "</p>" + "<p><b>Deadline: </b>" + Utilities.formatDate(CurrentRow[2], "GMT+2" , "dd.MM.yyyy") + "</p>";
How can I avoid this error?
You need Utilities.formatDate(Date, String, String).
CurrentRow[2] is coming up as type String, instead of Date.
If CurrentRow[2] is of a format that the Date object can parse, then try wrapping it in new Date(CurrentRow[2]).
strbody = strbody & "<font face=""Verdana"" size=""1""> <strong>" + Replace(name, "/", "-") + "</strong></font>"
When run the system to send out the email, there is no error in debug but the table interface will haywire because of this Replace().
I've tried as below but still not correct. Please help. Tq
Edit:
Replace(name, "/", "-") is correct syntax to use in code behind, but now I need to put it in html format in code behind for sending email. So I think I miss out some char to add. Like <font face=""Verdana"" , I need to put double "
'strbody = strbody & "<font face=""Verdana"" size=""1""> <strong>" + Replace(name, "" / "", "" - "") + "</strong></font>"
I have a report which has 6 parameters within it. What I would like to do is make these parameters part of my report heading. My parameters are as follows:
#BMDataType1 Text
#BMDataComp1 Float
#BMDataType2 Text
#BMDataComp2 Float
#BMDataType3 Text
#BMDataComp3 Float
There will always be an #BMDataType1 and #BMDataComp1 parameter passed, the others can be null. What I need the heading to look like is if only #BMDataType1 and #BMdataComp1 are passed then the heading should be for example:
Benchmark1 100% Benchmark Constituents
So far I have coded for this below:
=Parameters!BMDataType1.Value + " " + Parameters!BMDataComp1.Value.ToString + "%" + " Benchmark Constituents"
However if #BMDataType2 and #BMDataComp2 are populated then I need the heading to look like this:
Benchmark1 50% Benchmark2 50% Benchmark Constituents
Same for if 3 are passed then:
Benchmark1 50% Benchmark2 30% Benchmark3 20% Benchmark Constituents
There will never be say a Benchmark 1 and Benchmark 3. It will only be ever 1, or 1 and 2 or 1, 2 and 3.
Can someone point me in the right direction of how to write the IIF statement for this checking to see if Benchmark2 and Benchmark3 parameters are NULL?
Thanks
EDIT:
After some work on this I came up with the following code, but I'm still getting:
"Object reference not set to an instance of an object"
My code is the following:
=IIF(
IIF(IsNothing(Parameters!BMDataType1.Value),1,0)=0 AND IIF(IsNothing(Parameters!BMDataType2.Value),1,0)=1 AND IIF(IsNothing(Parameters!BMDataType3.Value),1,0)=1
, Parameters!BMDataType1.Value + " " + Parameters!BMDataComp1.Value.ToString + "%" + " Benchmark Constituents"
, IIF(
IIF(IsNothing(Parameters!BMDataType1.Value),1,0)=0 AND IIF(IsNothing(Parameters!BMDataType2.Value),1,0)=0 AND IIF(IsNothing(Parameters!BMDataType3.Value),1,0)=1
, Parameters!BMDataType1.Value + " " + Parameters!BMDataComp1.Value.ToString + "%" + " " + Parameters!BMDataType2.Value + " " + Parameters!BMDataComp2.Value.ToString + "%" + " Benchmark Constituents"
, IIF(
IIF(IsNothing(Parameters!BMDataType1.Value),1,0)=0 AND IIF(IsNothing(Parameters!BMDataType2.Value),1,0)=0 AND IIF(IsNothing(Parameters!BMDataType3.Value),1,0)=0
, Parameters!BMDataType1.Value + " " + Parameters!BMDataComp1.Value.ToString + "%" + " " + Parameters!BMDataType2.Value + " " + Parameters!BMDataComp2.Value.ToString + "%" + " " + Parameters!BMDataType3.Value + " " + Parameters!BMDataComp3.Value.ToString + "%" + " Benchmark Constituents"
, " ")))
However if all 3 parameters are not null it returns no error and it populates the heading as I would like it displayed. How can this be?
I have not been using SSRS since May, but string concatination in SSRS use VB syntax. So instead of concat strings with a + sign, you have to use the & sign.
=Parameters!BMDataType1.Value & " " & Parameters!BMDataComp1.Value.ToString & "%" & " Benchmark Constituents"
I found the solution to this and my code is as of below:
=Parameters!BMDataType1.Value + " " + CStr(Parameters!BMDataComp1.Value) + "% "
+ IIF(IIF(IsNothing(Parameters!BMDataType2.Value),1,0)=0,Parameters!BMDataType2.Value + " " + CStr(Parameters!BMDataComp2.Value)+"%","") + " "
+ IIF(IIF(IsNothing(Parameters!BMDataType3.Value),1,0)=0,Parameters!BMDataType3.Value + " " + CStr(Parameters!BMDataComp3.Value)+"%","") + " Benchmark Constituents"
For whatever reason it was not liking the .ToString which was returning "Oject reference not set to an instance of an object". By wrapping this in CStr I was able to remove the error and get the solution I required.
Thanks for all the responses, they all helped.
Something like this should work for you:
=Parameters!BMDataType1.Value + " " + Parameters!BMDataComp1.Value.ToString + "%" + IIf(IsNothing(Parameters!BMDataType3.Value) OR IsNothing(Parameters!BMDataComp3.Value), IIf(IsNothing(Parameters!BMDataType2.Value) OR IsNothing(Parameters!BMDataComp2.Value), " Benchmark Constituents", " " + Parameters!BMDataType2.Value + " " + Parameters!BMDataComp2.Value.ToString + "%" + " Benchmark Constituents"), " " + Parameters!BMDataType2.Value + " " + Parameters!BMDataComp2.Value.ToString + "%" + " " + Parameters!BMDataType3.Value + " " + Parameters!BMDataComp3.Value.ToString + "%" + " Benchmark Constituents")
I am trying to pass a HTML string to webview as following
String data = "<html>" +
"<body bgcolor=\"white \" align=\"center \" valign=\"center \">" +
"<table width=\"470\" height=\"725 \" >" +
"<tr>" +
"<td align=\"center\" valign=\"center\">" +
"<font color=\"gray\">" +
getResources().getString(R.string.loading) + //this is the string i want to localize
"</font>" +
"<br/>" +
"<br/>" +
"<br/>" +
"<br/>" +
"<br/>" +
"<img src=\"" +
"loading.gif" + //this the GIF i want to pass
"\">" +
"</td>" +
"</tr>" +
"</table>" +
"</body>" +
"</html>";
webview.loadData(data, "text/html", "UTF-8");
All works fine but that gif is not getting loaded.
Only reason for passing html is to localize that string "loading".Earlier It was in assets and the string "Loading" was hard coded in html file. now I am passing it by getting getting string resources (getResources().getString(R.string.loading)). Problem is passing "GIF".
Please help me to resolve this.
One solution to your problem is, save all this HTML code in to a file and put that file in the asset folder along with the image (gif) file. Then simply load that HTML file in the WebView. If you want to add any runtime values in the HTML, then add some placeholder strings into your HTML, and replace them at runtime with String.format(). In this way, you have to use the loadDataWithBaseURL() method to show the contents.