Crystal to SSRS conversion - reporting-services

DateValue(ToNumber(Mid({Command.Next_coupon_underlying_test}, 1, 4)),
ToNumber(Mid({Command.Next_coupon_underlying_test}, 6, 2)),
ToNumber(Mid({Command.Next_coupon_underlying_test}, 9, 2)))
I need to have SSRS Expression

As you have no supplied any sample data/values I can only assume that you have a date column that contains a date as a string in the format "2022-11-30" and that you want to convert this into a real date.
If this is true then you can do one of two things.
=CDate(Fields!myFieldName.Value)
Or if you really want to replicate the functionality of your existing expression then something like this...
=DATESERIAL(
MID(Fields!myFieldName.Value,1,4),
MID(Fields!myFieldName.Value,6,2),
MID(Fields!myFieldName.Value,9,2)
)
If this is not helpful, please edit your question and provide more information.

Related

Exclude Strings values for Totals Calculation in SSRS

I have question in SSRS report builder below is the data in column as
Site Information :
1,
2,
Not applicable.
So how to Calculate sum and percentage by excluding Not applicable text value .
Please help me
You can use the VAL() Function. This simply converts a string into a value is the string contains only data that can be viewed as a number.
So your expression would just be something like
=SUM(VAL(Fields!myTextField.Value))

SSRS standalone formulas

I have been working on this for days without being able to solve yet. It's probably simple if you know what you're doing. I'm simply trying to make a standalone formula that is not in a tablix or anything, it's just in a textbox.
Here is an example of my Dataset called Dataset1:
What I am trying to get is a sum of the Actual Cost when the Category is Labor from Dataset1. My current expression is:
=Sum(iif(Fields!Category.Value="Labor", Fields!ActualCost.Value, 0), "Dataset1")
I refer to Dataset1 as my scope because otherwise, I get an error about using an aggregate expression without a scope.
The report runs but shows #Error in the textbox that has my expression in it. When I replace Fields!ActualCost.Value with a 1, I get the answer, 5, which is the correct number of rows with Labor as the Category. But it won't let me sum the numbers in the ActualCost column where Category is Labor.
Any ideas as to what I'm doing wrong? I feel like it's something to do with aggregating, but I'm not sure. Thanks!
It may have to do with the datatype of fields!ActualCost.Value. If that field is a decimal (regardless of how you have it formatted), try using cdec(0) instead of just 0 in your expression.

Convert yyyymmdd number or string to true Date value in MS Access

I have a query that has a date field in this format (yyyymmdd) just numbers. I am reformatting the the field by creating a calculated field using the following formula:
[DateField] = Date(Left( [DateField] ,4),Mid( [DateField] ,5,2),Right( [DateField] ,2))
I keep getting a message saying my formula contains wrong number of arguments!!
This formula always worked in Excel.
Please advise
Cheers
In Access you'll need to use the DateSerial() function:
DateSerial(Left([DateField], 4), Mid([DateField], 5, 2), Right([DateField], 2))
I recommend using CDate function and type in the appropriate format for date
NewDate: CDate(Format([TextField], "0000-00-00"))

sorting string numeric values in SSRS 2008

I have a varchar field (i am grouping on) in a dataset that returns a list of values : 20, 25, 40, 100, 110, 'N/A'..
I want the "numeric" values sorted from low to high : i.e : 20, 25...110, 'N/A'
the problem is that the A>Z sorting in the grouping gives out the following output :
100, 110, 25, ..., N/A
I cannot convert to numeric datatype since there are string values..
Does anyone have a solution please ?
Thank you in advance
Jam
There are several solutions you can implement here. I'll discuss the two I consider to be the easiest. If these don't work for you, let me know because there are a multitude of options. To make it easy, I've named the field you're referring to in your question as *num_text*.
Fix in SSRS:
Go to the Tablix Properties for the tablix displaying the data in question. Go to Sorting tab. Click Add. In the "Sort by" field, click the expression button and type the following:
=CInt(IIF(Fields!num_text.value = "N/A",9999999,Fields!num_text.value))
Note, you need to convert any possible text values to a number greater than any possible integer/decimal. In this case I chose 9999999 based on the examples in your question. If you have multiple text values that are not converted to number, Report Builder/BIDS will allow you to save the report, but when you render it, it will show #Error, signifying that the CInt (or any other conversion formula you choose) failed on a non-numeric value.
Fix in SQL:
Add a new field (like field_sort) with datatype numeric and use your case statement generating the current field in question saying:
, Case
When --Criteria leading to "N/A"
Then 9999999
Else num_text
End as field_sort
--Rest of SQL Script here
Order by field_sort
Then just display your num_text field in SSRS, and the values will be sorted properly. If you have many possible string values, then you might find it easier to fix in SQL (rather than specifying numerous IIF statements in SSRS.

Expression for getting total value of a field etc

I need help for the following
1) Could you give me expression for getting total of a field in SSRS
2) My date saved in database is mm/dd/yy, when shown in report, I want to show it like May 21, 2011, How?
Thanks a lot.
Furqan
1) =Sum(Fields!YourField.Value)
2) =Format(Parameters!DateField.Value,"MMM dd,yyyy")
This answer your questions?