Need help "translating" an excel formula to an SSRS expression - reporting-services

How do I translate a nested If() Excel formula to SSRS language?
I have not attempted yet, don't know how to even start. I'm a newbie in ssrs.
the Excel formula is as follows:
=IF(A1>B1,"NO TEST",(IF(C1="4567","NEW","OLD")))
NOTE: A and B are datetime values, C is data type char(6) {either "OK" or "4567"}. B can be NULL.
What I want to accomplish is to show in a textbox in my report either "NO TEST", "NEW" or "OLD".

Similar like in Excel. 4567 for a number and "4567" for a string:
=IFF(CDate(Fields!A1.Value) > IFF(IsDate(Fields!B1.Value), Fields!B1.Value, "01.01.1900"), "No Test", IFF(Fields!C1.Value = "4567", "New", "Old"))
If B1 can be null you have to filter it away or you check for Null, because theCDate() function will throw an error with Null.

Related

In Microsoft report bulider, how to convert integer to string

I have one integer data in my dataset column. I want to convert the integer value to string.
For example: I have a column like class ID: 100, 200,300,...etc
I need to change the "Class ID"data like
100 means it displays "Class A"
200 means it displays "Class B"
How can I do this convertion in Microsoft report bulider 2016
There are a few ways to do this. If you plan to use the same logic in more than one place then it would be a good idea to create a table in your database with a ClassID and ClassName so you can just join to this table in your query to return the ClassName.
If for some reason you cannot do this then you can do it with expressions in SSRS directly.
Your expression would look something like this.
=SWITCH (
Fields!ClassID.Value = 100, "Class A",
Fields!ClassID.Value = 200, "Class B",
Fields!ClassID.Value = 300, "Class C",
True, "Unknown Class"
)
The final True acts like an else, so if none of the previous expressions match then '"Unknown Class"' would be returned.

SSRS Report Shows #Error When Converting Number to Currency

I am trying to get the report to show the purchase price which the user enters in a parameter. If the user doesn't enter anything it will say "Undisclosed" otherwise I want it to show the purchase price as currency. I have tried the following:
=IIF(Parameters!PurchasePrice.Value = "", "Undisclosed", Cstr(Format(Parameters!PurchasePrice.Value, "C")))
=IIF(Parameters!PurchasePrice.Value = "", "Undisclosed", Format(Parameters!PurchasePrice.Value, "C"))
=IIF(Parameters!PurchasePrice.Value = "", "Undiscloded", FormatCurrency(Parameters!PurchasePrice.Value,0))
=IIF(Parameters!PurchasePrice.Value = "", "Undiscloded", FormatNumber(Parameters!PurchasePrice.Value,0))
I can get "Undisclosed" to appear but every time I enter a number it shows #Error
You can try the following solution:
=IIF(IsNumeric(Parameters!PurchasePrice.Value), Format(Val(Parameters!PurchasePrice.Value), "C"), "Undisclosed")
I would approach this slightly differently. This will avoid SSRS trying to format a non numeric to a currency. IIF will evaluate both the true and false outcomes even though only one result can be true for each instance.
I would set the textbox that shows the purchase price up as follow...
Set the Value expression to be
=VAL(Parameters!PurchasePrice.Value)
This will return a zero if the parameter value is left as blank/empty string
Then set the Format property of the textbox to
$#.00;-$#.00;Undisclosed
Assuming you want $ as the currency symbol. This format string will format the number to two decimals for positive and negative numbers and prefix the $ symbol but for zero values, it will show the work "Undisclosed"

SSRS REPORT BUILDER, Comparing two diffrent data sets in one Tablix, Expression

I have two datasets and want to compare them in an expression.
I would like to do something like this:
=iif(Fields!Grade.Value = "ONGRADE" > LookupSet(Fields!Grade.Value = "ONGRADE", Fields!grade.Value = "ONGRADE" , Fields!grade.Value = "ONGRADE", "Previous3Week"), "UP" ,"DOWN")
This currently returns "Error" within the "ONGRADE" row.
you need to bind your component with one of the datasets and then accordingly you can write following expression :
=iif(Fields!grade.Value > (Fields!grade.Value, "ONGRADE_DataSet2") , "UP", "DOWN")
in this example, the component is binded with the first dataset and the second dataset is getting referred.
This may help.

Check if JSON string in Orbeon repeating grid contains a specific value

Working with the repeating grids through the form builder.
I have a custom control that has a string value represented in json.
{
"data": {
"type": "File",
"itemID": "12345",
"name": "Annual Summary",
"parentFolderID": "fileID",
"owner": "Owner",
"lastModifiedDate": "2016-10-17 22:48:05Z"
}
}
In the controls outside of the repeating grid, i need to check if name = "Annual Summary"
Previously, i had a drop down control and using Calculated Value $dropdownControl = "Annual Summary" it was able to return true if any of the repeated rows contained the value. My understanding is that using the = operator, it will validate against all rows.
Now with the json output of the control, I am attempting to use
contains($jsonStringValue, 'Annual Summary')
However, this only works with one entry and will be null if there are multiple rows.
2 questions:
How would validate whether "Annual Summary" (or any other text) is present within any of the repeated rows?
Is there any way to navigate the json or parse it to XML and navigate it?
Constraint:
within the Calculated Value or Visibility fields within form builder
manipulating the source that is generated by the form builder
You probably want to parse the JSON string first. See also this other Stackoverflow question.
Until Orbeon Forms 2016.3 is released, you would write:
(
for $v in $jsonStringValue
return converter:jsonStringToXml($v)
)//name = 'Annual Summary'
With the above, you also need to scope the namespace:
xmlns:converter="org.orbeon.oxf.json.Converter"
Once Orbeon Forms 2016.3 is released you can switch to:
$jsonStringValue/xxf:json-to-xml()//name = 'Annual Summary'

SSRS how to hide supreports based on dataset field

I have a master report in SSRS/SSDT that contains several subreports....I see the Dataset on the master report has the "status" field in there as a field from the stored procedure. I would like to suppress/hide 3 sub reports if the status is '4'. going about it via the UI in SSRS/SSDT.
Goal to use expression to do following:
if status = 4
suppress following subreports. rpt 1, rpt2, rpt3
I imagine i would need to modify the UI for the 3 sub reports.
OPTIONS: rclick sub report, select subreport properties - Visibility - show or hide based on an expression fx.
Need Help with the expression.
=IIF(Fields!Status.Value, "4") TRUE, FALSE)
If the sub report is inside a table or Matrix that has its dataset set to the one containing Status and you are showing the sub report for each row of data then.
=IIF(Fields!Status.Value = "4", TRUE, FALSE)
Otherwise you can use the first value contained in the dataset to make the decision like this.
=iif(First(Fields!Status.Value,"DataSetName") = "4" , TRUE, FALSE)