I have a report that can be grouped monthly, quarterly, or annually. With my data, I have two columns, ActivationYear and ActivationMonthOrQuarter. I get ActivationMonthOrQuarter when I run the report, so I can have values ranging from 1-12 (1-12 if monthly, 1-4 if quarterly). If the grouping option is annually the ActivationMonthOrQuarter field will be null.
The issue I am running into is that it seems to still try and call the MONTHNAME function even when I use GroupingOption = "Annual" and throws an error since it cannot call it on a NULL value.
=SWITCH(
Parameters!GroupingOption.Value = "Annual", "",
Parameters!GroupingOption.Value = "Quarterly", "Q" & Fields!ActivationMonthOrQuarter.Value,
Parameters!GroupingOption.Value = "Monthly", MONTHNAME(Fields!ActivationMonthOrQuarter.Value)
)
Try:
=SWITCH(
Parameters!GroupingOption.Value = "Annual", "",
Parameters!GroupingOption.Value = "Quarterly", "Q" & Fields!ActivationMonthOrQuarter.Value,
Parameters!GroupingOption.Value = "Monthly", MONTHNAME(IIF(IsNothing(Fields!ActivationMonthOrQuarter.Value),1,Fields!ActivationMonthOrQuarter.Value))
)
Let me know if this helps.
Related
In SSRS Expression, how to count the numbers of rows that present in today or yesterday in dataset with other equivalent condition,
For example
=COUNT(IIF(
DateDiff(DateInterval.Day,Cdate("01/01/1900"),Fields!Opendate.Value) =
DateDiff(DateInterval.Day,Cdate("01/01/1900"), Now()), Fields!Opendate.Value, Nothing))
Using this expression I can check get the total count for today, it's working.
I need to add to check today date with other condition like:
If (today date and Fields!reason.Value = "Other")
It's not working when I add reason value to check :
=COUNT(IIF(
DateDiff(DateInterval.Day, Cdate("01/01/1900"), Fields!Opendate.Value) =
DateDiff(DateInterval.Day, Cdate("01/01/1900"), Now()) -1, Fields!Opendate.Value, Nothing ) **And Fields!reason.Value = "Other"**)
Please guide me
Just add it in your IIF() statement:
=COUNT(IIF(
DateDiff(DateInterval.Day, Cdate("01/01/1900"), Fields!Opendate.Value) =
DateDiff(DateInterval.Day, Cdate("01/01/1900")
And Fields!reason.Value = "Other",
Now()) -1,
Fields!Opendate.Value,
Nothing
)
)
I have a report which creates a spreadsheet. one cell could have data from one of three fields depending on a fourth field status or field two being blank..
I was thinking of writing as CASE statement but that does not work in ssrs.
The IIF statement works great for 2 values but how do you write for three values?
In common language it would be "If secondary value ="Yes", use secondary name, If account field value is Null, use Contact field value, otherwise use account field value"
Thanks
You can use nested IIF statements but they quickly get messy. You should use SWITCH which acts a bit like a case statement.
A simple example would be
= SWITCH(
Fields!myFirstField.Value = <10 , "Small",
Fields!myFirstField.Value = <30 , "Medium",
Fields!myFirstField.Value = <80 , "Large",
True , "HUGE",
)
As switch stops at the first true expression there is not need to check ranges of values if you get them in the correct order.
The final "True" expression just acts like an ELSE
If you need to check multiple criteria per condition then you can do that too like this..
= SWITCH(
Fields!myFirstField.Value = <10 AND Fields!mySecondField.Value = 1 , "Small Cat",
Fields!myFirstField.Value = <10 AND Fields!mySecondField.Value = 2 , "Small Dog",
Fields!myFirstField.Value = <30 , "Medium Animal",
Fields!myFirstField.Value = <80 , "Large Animal",
True , "HUGE Animal",
)
I have a column (Say PriceA) in SSRS which gets populated based of Expression.
PriceA.value
IIF((Fields!MOP.Value = "PRIV" OR Fields!MOP.Value = "FACI" OR Fields!MOP.Value = "GUAR" OR Fields!MOP.Value = "CASH"
OR Fields!MOP.Value = "CHRG" OR Fields!MOP.Value = "INV"),
IIF(Fields!UDRx.Value,"U/D",Fields!TtlPrice.Value),
IIF(Fields!elecadj.Value="0" AND Fields!elecadj2.Value="0", IIF(Fields!UDRx.Value,"U/D",IIF(Fields!MOP2.Value="0",Fields!Copay.Value,"")),
IIF(Fields!UDRx.Value,"U/D",Fields!PatientPayAmt.Value)
)
)
The Value in PriceA can be "U/D" or Zero or some value as "150.00". Now I want to display at the end of the report, an aggregate of the rows in that column, discarding the values $0.0 and "U/D".
How do I do that?
I also have another column where it shows values based off off 2 different expression, that I need to aggregate. That one is not working either.
2ndPriceA_expression
IIF((Fields!MOP.Value = "PRIV" OR Fields!MOP.Value = "FACI" OR Fields!MOP.Value = "GUAR" OR Fields!MOP.Value = "CASH"
OR Fields!MOP.Value = "CHRG" OR Fields!MOP.Value = "INV"), " ",
IIF(Fields!elecadj.Value="0" AND Fields!elecadj2.Value="0",
IIF(Fields!UDRx.Value="0",Format(Fields!TtlPrice.Value,"C"),"U/D") ,
IIF(Fields!UDRx.Value="0",Format(Fields!Payor1PaidAmt.Value,"C"),"U/D")
)
)
2ndPriceB_expression
IIF(Fields!MOP2.Value<>"",
IIF(Fields!elecadj.Value="0" and Fields!elecadj2.Value="0"
,IIF(Fields!UDRx.Value="1","U/D",Fields!Copay.Value)
,IIF(Fields!UDRx.Value="1"
,"U/D"
,IIF(Fields!elecadj2.Value="0"
,Fields!Copay.Value
,Fields!Payor2PaidAmt.Value
)
)
)
," ")
I need to show aggregate of 2ndPriceA & 2ndPriceB in a 3rd cell. Sorry I'm 2 weeks new to SSRS.
Thanks in advance. any help is appreciated.
Just do a SUM() of an IIF() expression that will filter out the values you don't want to SUM.
I have the following query:
DoCmd.OpenForm "BPRIL Data Entry", , , "[Deleted]<>-1 Or [Deleted] Is Null", acFormEdit, , ""
How do I sort by ascending.
I know it's something like ORDER BY ASC but I don't know where to place it.
You can use properties of the form once it is open:
Forms![BPRIL Data Entry].OrderBy = "Something"
Forms![BPRIL Data Entry].OrderByOn = True
Ascending is the default.
I am trying to use a expression within an expression in SSRS and it's getting really complicated. Is there a way around this?
For example if I have a number of sales and number of contacts I can create the conversion rate by dividing the sales into the contacts ie
=fields!sales.value/fields!contacts.value
What I want to do next is use this to put the sales people into various bands so that those with a conversion rate in thresholds are displayed in bandings.
=iif(fields!sales.value/fields!contacts.value<0.5,"poor","Ok")
This is fine for 2 bandings (ok and poor), but gets more complicated for the 5 bandings I want.
I must be able to define the first variable and then use that within the iif statement?
How do I do this in SSRS 2008?
Thanks in advance.
Better to use Switch which returns the first true condition
=Switch(
fields!sales.value/fields!contacts.value < value1, "very poor",
fields!sales.value/fields!contacts.value < value2, "poor",
...
fields!sales.value/fields!contacts.value < value(n-2), "good",
fields!sales.value/fields!contacts.value < value(n-1), "very good",
True, "excellent"
)
where value1 < value2 < ... < valuen.
The final True is dummy like the use of default in an SQL Case expression
An alternative is using custom vb code you can create a function
Public Function GetRating( ByVal rating As Decimal ) As String
Select Case rating
Case Is < value1
Return "poor"
...
Case Is < valuen
return "very good"
Case Else
Return "excellent"
End Function
Then in the rows use the expression
= Code.GetRating( fields!sales.value/fields!contacts.value )