Home > OS >  SSRS , Not clear where I should change my code to get away from the overload IIF parameter problem i
SSRS , Not clear where I should change my code to get away from the overload IIF parameter problem i

Time:07-11

So I am trying to resolve the case where I have two fields namely 'Success' and 'Fail'. I want to show the value of the 'Success' field as 100 when both fields(Success and Fail) are zero but in case the 'Fail field has a value other than zero but the value of the 'Success' field is still 0, I want success field to show '0' while 'Fail' should show the appropriate value.

For this I have written the below expression with nested iif loops, I am new to SSRS reporting. So any help/suggestions will be highly appreciated. Thanks.

SSRS Expression:

=iif(Fields!CountAlwaysOnSuccess.Value=0,100,iif(Fields!CountAlwaysOnFail.Value!=0,Fields!Always_On_SLO_Success.Value)) & "%," & Fields!CountAlwaysOnSuccess.Value

This is the error that I am getting for my expression above:

The Value expression for the textrun ‘Textbox2.Paragraphs[0].TextRuns[0]’ contains an error: [BC30516] Overload resolution failed because no accessible 'IIf' accepts this number of arguments.

CodePudding user response:

The IIF function takes three parameters:

IIF(Condition, ValueWhenTrue, ValueWhenFalse)

You say that you want to display:

  • 100% when both Success and Fail are zero
  • 0%, <FailValue> when Success is zero and Fail is non-zero

However, your formula displays the Always_On_SLO_Success field when Fail is non-zero. It looks like we can display these two fields when either Success or Fail are non-zero, so I don't think you need your second conditional. You probably also need to cast your numeric fields to string. Try something like this:

=IIF(Fields!CountAlwaysOnSuccess.Value   Fields!CountAlwaysOnFail.Value = 0, 
    "100%", 
    CStr(Fields!Always_On_SLO_Success.Value) & "%," & CStr(Fields!CountAlwaysOnFail.Value) & "%")
  • Related