Substring value in ssrs to get only month number - reporting-services

When I´m running ssrs I have an issue with my field month because value is:
[Dim_Tiempo_].[Mes].&[6]
So I try to substring to get only value 6:
=CINT(Left(Right(Parameters!DimTiempoMes.Value(0),3),2))
But I just get #Error without specifications why. Can someone help me there?

When you go right and get the last 3 characters, you get [6], then you go left 2, you get [6.. converting this to an int is obviously going to return and error. if you didn't put the CINT.. you would have seen what was happening.. what you need is the following
=cint(replace(left(Split(Parameters!DimTiempoMes.Value(0),"[").GetValue(3),2),"]",""))

Related

SSRS Format Number Separator

I have a field in SSRS that returns the value of numbers varying from ## to #######. I want these numbers to be separated by thousands. I have seen a few posts saying you could use this:
=Format(Fields!Number.Value,"#,#.##")
However, I have this textbox to display data from a different dataset, like:
=First(Fields!Price.Value, "DataSet3")
Now, the question is how do I combine both? Is it possible to wrap it like this:
=Format(First(Fields!Price.Value, "DataSet3"),"#,#.##")
If I do this and run the report then the output on the text field is just #,#.## and not the actual number itself.
Input: 100000000
Output that I expect: 100,000,000
Output that I get: #,#.##
Any help is much appreciated. Thanks!
This is definitely some weird functionality. I didn't figure out exactly what was causing it, but I found that adding a datatype cast to the expression resolved the issue.
=FORMAT(CDec(First(Fields!XYZColumn.Value, "ZYXTable")), "#,#.##")

How to stop rounding in ssrs report

I have an SSRS report that is rounding currency and I need the report to show the actual value. When I run the query in query designer all the values are shown correctly. If I output this to Excel and SUM the values I get the total I expect (e.g £56724.30)
When I run the report I get the value £56840.00 so it looks as if the data being used is getting rounded before output.
I have a Calculated field in the report called Total_Rent_Due_UC_Claims:
=iif(Fields!UC_Rent.Value = Fields!LastCharge.Value, Fields!UC_Rent.Value, 0) or
iif(Fields!UC_Rent_Date.Value = Fields!LastCharge.Value and
Fields!extra10a_d003.Value < Parameters!AsAtDate.Value, 0, Fields!UC_Rent_Date.Value)
I then use this to get a total:
=Sum(Fields!Total_Rent_Due_UC_Claims.Value)
I have formatted this field to currency to two decimal places.
Can someone assist with this so that the value in the report is the same as the expected value?
I don't think this difference can be attributed to rounding -- at least not any rounding I've ever seen before. That's a difference of £115.70. I think the calculated field isn't quite doing what you want it to and needs a little modification. I'm not exactly sure what it's doing right now, but basically both of those IIF statements will evaluate because OR doesn't really work the way you have it. I would try the following expression.
=IIF(Fields!UC_Rent.Value = Fields!LastCharge.Value,
Fields!UC_Rent.Value, IIF(Fields!UC_Rent_Date.Value = Fields!LastCharge.Value
AND Fields!extra10a_d003.Value < Parameters!AsAtDate.Value, 0, Fields!UC_Rent_Date.Value))
Of course, this could still be wrong as I can't tell if all of the fields are date datatypes or if there's some kind of mismatch going on here. Let me know if this doesn't work and I'll see if I can adjust it.

SSRS- SUM in IIF not working

I am new into SSRS and trying to retrieve the sum of the column when the column CODATE = 0.
The expression I am using is as follows:
=SUM(IIF(Fields!CODATE.Value=0,Fields!CURBAL.Value,00.00))
The rendering is not happening at all. However, when I am just trying the IIF, it works fine. What could be wrong?
The data types of the variables are as follows:
CODATE: int
CURBAL: float(null allowed).
I basically want to sum all the values when the codate column is 0, but it isnt working. I get a warning for telling rsAggregateofNonNumericData.
It may be treating 0 as null. Try converting with cint/cdec:
=SUM(IIF(Fields!CODATE.Value=cint(0),Fields!CURBAL.Value,cdec(00.00)))

expression in split component in SSIS giving error

I am trying to implement conditional split component in my SSIS package. I need to split the records based on the year. I need to extract data for the last 5 years and need to split it before i dump it to the destination
periodenddate is datetime field. I need to extract the year part from that field and compare it against the actual year as mentioned in the expression. I am getting an error for invalid expression. Could somebody tell me where am i going wrong
The expression i am using is for eg
periodEndDate == YEAR(GETDATE())
Please find the error attached
Second error
Third error
If you want the year number from one year ago, you need to use:
YEAR([periodenddate]) = YEAR(GETDATE()) - 1
YEAR([periodenddate]) = YEAR(GETDATE()) - 2
etc.
Having the "-1" inside the parentheses for the Year() function will give you the wrong answer at the very least.
Note that you got different errors with each version of your code:
The first image shows a failure to find a field due to SSIS being case sensitive
The second image shows a failure due to comparing a datetimestamp to an integer
The third image shows an error with the expression "GETDATE() - 1", which is on a different conditional expression component than the first two images.

SSRS How to Add Max Expression to an Existing Expression

I have the following code and I now want to only show the max or distinct values for a single field within SSRS.
=Join(LookUpSet(Fields!Baseacctnbr.Value,
Fields!Baseacctnbr.Value,
Fields!Acctnbr.Value,
"DataSet1"), ",")
Right now with this expression the code brings back all the accounts, but it brings back multiples of the same account because of the SQL query and other data that is needed. I would like to only show the MAX or Distinct values of the AcctNbr on a single field within SSRS.
Is there a way to add the MAX expression to this existing expression?
UPDATE:
When I add the SSRS Code Block found on another question, then I receive an error message that states: "Too many arguments to 'Public Shared Function RemoveDuplicates(m_Array() As Object) As String()."
Thanks.
I removed the close brace and it worked fine. I had also entered this code before your response and it worked fine since the account is actually 8 characters long.
=Join(Code.RemoveDuplicates(LookupSet(Left(Fields!BaseAcctNbr.Value, 8), Fields!BaseAcctNbr.Value, Fields!AllPhase3AcctNbrs.Value, "DataSet1")), ",")
Thanks for your help!