SSRS Expression Assistance - reporting-services

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?

Related

How to convert datetime which is in Text format in Excel to yyyy-mm-dd HH-MM-ss in ssis derived column Expression

I was trying this expression but still getting error
((DT_STR,4000,1252)(LEFT(TOKEN([Date] ,"/",1),4) + "-" + RIGHT("0" + TOKEN([Date] ,"/",2),2) + "-" + RIGHT("0" + TOKEN([Date] ,"/",3),2) + " " ++ " " + TOKEN([Date] ,":",4)+ "-" + RIGHT("0" + TOKEN([Date] ,":",5),2) + "-" + RIGHT("0" + TOKEN([Date] ,":",6),2)))
Personally, I would use a script task. This assumes your string will always Parse to a DateTime. If not, look into TryParse().
Also, ParseExact() is even better but you didn't provide an example.
DateTime dt = DateTime.Parse(your date string);
string dtFormatted = dt.ToString("yyyy-MM-dd hh:mm:ss");
I will add one more caveat. You should probably treat this as a date and only format the date on the presentation layer.

Breakline not working SSRS formula or calculated fields?

picture probleme breakline
, I have a problem with my breakline not working properly in my either caculated fields or my expression.
I would like to split by created date and title etc...
do you know why it is not working ?
= "<b>"+ "Created on: " + "</b>" & CDate(Fields!ticket_ticketSolutions_date_create.Value).ToString("dd/MM/yy HH:mm")
& Environment.NewLine & Environment.NewLine &
"<b>" + "Approval date: " + "</b>" & iif(IsNothing(Fields!date_approval.value),"Not Approved",CDate( Fields!date_approval.Value).ToString("dd/MM/yy HH:mm"))
& Environment.NewLine &
Environment.NewLine &
"<b>" + "Solutions: " +"</b>" & Fields!ticket_ticketSolutions_content_plainText.Value
=Join( LookupSet(Fields!ticket_tickets_sourceId.value, Fields!itemId.value, Fields!start_end_solution_data.value, "Ticket_ticket_ticket_Solutions"), vbcrlf)
calculated fields ,
expression
It looks like you are using HTML tags in your text box. When using HTML, line breaks do not work.
Replace the NewLine with the HTML break tag <br>.
= "<b>"+ "Created on: " + "</b>" & CDate(Fields!ticket_ticketSolutions_date_create.Value).ToString("dd/MM/yy HH:mm") &
"<br><br>" & "<b>" + "Approval date: " + "</b>" &
IIF(IsNothing(Fields!date_approval.value), "Not Approved", CDate( Fields!date_approval.Value).ToString("dd/MM/yy HH:mm")) &
"<br>" & "<br>" & "<b>" + "Solutions: " +"</b>" & Fields!ticket_ticketSolutions_content_plainText.Value

Date formatting in Google Scripts/Mail - Method not found Error

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]).

SSRS - Expression to create string for reporting heading

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")

SSRS datepart expression, Error

I didnt know whats wrong with this expression.This expression always return #error.how to solve this?
=MonthName(datepart("M",format(Fields!date.Value,"yyyy-MM-dd"))) + " " + datepart("yyyy",format(Fields!date.Value,"yyyy-MM-dd"))
expression works fine with just=MonthName(datepart("M",format(Fields!date.Value,"yyyy-MM-dd"))), when added + " " + datepart("yyyy",format(Fields!date.Value,"yyyy-MM-dd")) become error.curious.
Use & instead of + to concatenate strings in SSRS expressions - Operators in Expressions (Report Builder and SSRS)
=MonthName(datepart("M",format(Fields!date.Value,"yyyy-MM-dd"))) & " " & datepart("yyyy",format(Fields!date.Value,"yyyy-MM-dd"))
Try ===>
=MonthName(datepart("m",format(Fields!date.Value,"yyyy-MM-dd"))) + " " + datepart("y",format(Fields!date.Value,"yyyy-MM-dd"))