Search code examples
reporting-servicescrystal-reportsmigrationssrs-2008reporting

I am converting Crystal reports to SSRS reports. Need to convert an IIF expression with multiple arguments


I need to convert an expression with multiple arguments. Below is the crystal expression

if Sum ({t_bol_cartons.no_of_cartons}, {t_bol_cartons.hu_id}) = 0 and {t_bol_cartons.sub_status} <> 'S' and {t_bol_cartons.loaded} <> 0 then 1 
else if Sum ({t_bol_cartons.no_of_cartons}, {t_bol_cartons.hu_id}) = 0 and {t_bol_cartons.loaded} = 0  then 0
ELSE Sum ({t_bol_cartons.no_of_cartons}, {t_bol_cartons.hu_id})

I have converted in SSRS as below

IIf((Fields!no_of_cartons + Value,Fields!hu_id.Value = 0) AND
(Fields!sub_status.Value <> "S") AND (Fields!loaded.Value <> 0),"1",
IIf((Fields!no_of_cartons.Value + Fields!hu_id.Value = 0) AND (Fields!loaded.Value = 0),"0",
(Fields!no_of_cartons.Value + Fields!hu_id.Value)))

I am getting an error as

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

Please could anyone help with this? Thank you.


Solution

  • The is first part is wrong, you have Fields!no_of_cartons + Value instead of Fields!no_of_cartons.Value

    Try

    IIf(
      (Fields!no_of_cartons.Value + Fields!hu_id.Value = 0) AND (Fields!sub_status.Value <> "S") AND (Fields!loaded.Value <> 0),
      "1", 
      IIf(
          (Fields!no_of_cartons.Value + Fields!hu_id.Value = 0) AND (Fields!loaded.Value = 0),
          "0",
          (Fields!no_of_cartons.Value + Fields!hu_id.Value)
          )
        )