ssrs parameter expression condition - reporting-services

In SSRS (2014) I have created the Placeholder.
The value of Placeholder is picks from SQL 2014 DB StoredProcedure.
In the Placeholder properties, I have below expression,
=Parameters!BRN.Value
When I run the report,
Step 1: Report asks BRN value (which is integer). When I enter value
as "1"
Step 2: Report displays 1
If I pass BRN value as 2
it displays 2
But I want below results,
Step 1: When Report asks BRN value (which is integer). If I enter value
as "1" then it should display as "Winter"
or If I enter value
as "2" then it should display as "Summer"
or If I enter value
as "3" then it should display as "Spring"
or If I enter value
as "4" then it should display as "Sunny"
How can I do this please?

=Switch(Parameters!BRN.Value = 1, "Winter", Parameters!BRN.Value = 2, "Summer", Parameters!BRN.Value = 3, "Spring", Parameters!BRN.Value = 4, "Sunny")

Related

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"

Using SUM with a switch function in Report builder 3.0

I have a column of data called Date and I am using that to perform a switch. Basically the figure needs to be 120 on a weekday and 0 on a weekend so I have used.
=SWITCH
(Weekday(Fields!Date.Value) = "1", "0",
Weekday(Fields!Date.Value) = "2", "120",
Weekday(Fields!Date.Value) = "3", "120",
Weekday(Fields!Date.Value) = "4", "120",
Weekday(Fields!Date.Value) = "5", "120",
Weekday(Fields!Date.Value) = "6", "120",
Weekday(Fields!Date.Value) = "7", "0"
)
Which works great. However I also want a Total at the bottom of the sheet. I (somewhat naively) tried adding
=SUM( ... )
to the expression but that resulted in an #Error in the textbox. I also tried
=SUM(ReportItems!Textbox85.value)
and that didn't even run throwing the error
The Value expression for the textrun
'Textbox84.Paragraphs[0].TextRuns[0]' uses an aggregate function on a
report item. Aggregate functions can be used only on report items
contained in page headers and footers.
So my question is how do I sum up this switch function or do I need to rethink this? I guess functionally all I really need is count of the total weekdays so far "this" month (that stays accurate no matter what month is picked using the date parameters). I can then * that number by 120.
So I came at it from a different angle and tried a SQL based solution. I added a column with the code
,CASE
WHEN
DATEPART(dw,convert(date,format(dateadd(hh,1,[Start Time]),'dd/MM/yyyy'),103)) in (1,7)
THEN 0
ELSE 1
End as [weekday]
Then used
=Fields!weekday.Value*120
in my textbox and
=Sum(Fields!weekday.Value, "DataSet1")*120
in my total. Got the desired results.

SSRS Filter by parameter and Value condition

I am trying to add an parameter that will allow the user to filter by unit Cost. I.e. If for parameter Unit cost, User select "All Costs", it will not perform any filter and will show all items. However, if for the parameter Unit cost, the user selects "Greater than 0" it would only display items that have unit cost > 0.
I have declared the parameter with two available values "U" and A".
However, what would the Parameter condition look like? I tried adding the condition which was =IIF(Parameter!Text.Value = "U", UnitCost, NOTHING) > 0.
This doesn't seem to be working though. Can anyone provide suggestions as to how this would be done.
You can use an expression to determine if a row should be filtered or not based on the parameter selected value.
Add a new Filter condition in your tablix and use these settings and expressions:
In Expression textbox use:
=Switch(
Parameters!Text.Value = "All", "Include",
Parameters!Text.Value = "U" AND Fields!UnitCost.Value > 0, "Include",
Parameters!Text.Value = "A" AND Fields!UnitCost.Value > 10, "Include",
true, "Exclude"
)
In the Value textbox use:
="Include"
Note your parameter should have an available value as conditions to filter you need.
In this case I use A parameter value to filter the UnitCost values greater than 10 and U value to filter UnitCost values greater than 0. Customize to meet your requeriment.
Let me know if this helps.

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)

SSRS - Match previous value then display something

Example:
Name: (a field name that display "people name")
His/her information: (match the name then pull out the field value of their "first/last name", "address
, "phone"....etc each represent 1 field value, so it need to pull out 4 field value)
Any advice or what function to use will be appreciate.
thanks for helping!!