none
SSRS Expression divide by zero error RRS feed

  • Question

  • Hi, I am getting an error in SSRS calculating the field that potentially divide by zero. may i ask your help to fix this issue. thanks.

    =First(Fields!CEQ_all.Value, "DailyUpdates_DS") = value is zero
    =Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS")= value is 0.16
    
    
    --This is the codes in my field expression
    =IIF(First(Fields!CEQ_all.Value, "DailyUpdates_DS")>Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS"),Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS")/First(Fields!CEQ_all.Value, "DailyUpdates_DS"),1)

    Tuesday, July 8, 2014 8:33 AM

Answers

  • try like this

    =IIF(First(Fields!CEQ_all.Value, "DailyUpdates_DS")>Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS"),Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS")/IIF(First(Fields!CEQ_all.Value, "DailyUpdates_DS")>0,First(Fields!CEQ_all.Value, "DailyUpdates_DS"),Nothing),1)


    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

    • Marked as answer by Lenoj Wednesday, July 9, 2014 1:40 AM
    Tuesday, July 8, 2014 9:42 AM
  • Hi Try the below answer.

    =IIF((First(Fields!CEQ_all.Value, "DailyUpdates_DS")<>0 And First(Fields!CEQ_all.Value, "DailyUpdates_DS")>Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS")),Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS")/First(Fields!CEQ_all.Value, "DailyUpdates_DS"),1)

    Please Mark This As Answer if it helps to solve the issue

    • Marked as answer by Lenoj Wednesday, July 9, 2014 1:39 AM
    Tuesday, July 8, 2014 10:02 AM

All replies

  • According to your description;

    =First(Fields!CEQ_all.Value, "DailyUpdates_DS") = value is zero
    =Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS")= value is 0.16

    it will be
    =IIF(0>0.16,(0.16/0),1)

    SO This will return false then value will be 1.
    that will here division between values will not perform.


    Please share exact error for better understanding.

    Thanks

    Tuesday, July 8, 2014 9:23 AM
  • try like this

    =IIF(First(Fields!CEQ_all.Value, "DailyUpdates_DS")>Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS"),Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS")/IIF(First(Fields!CEQ_all.Value, "DailyUpdates_DS")>0,First(Fields!CEQ_all.Value, "DailyUpdates_DS"),Nothing),1)


    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

    • Marked as answer by Lenoj Wednesday, July 9, 2014 1:40 AM
    Tuesday, July 8, 2014 9:42 AM
  • Hi Try the below answer.

    =IIF((First(Fields!CEQ_all.Value, "DailyUpdates_DS")<>0 And First(Fields!CEQ_all.Value, "DailyUpdates_DS")>Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS")),Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS")/First(Fields!CEQ_all.Value, "DailyUpdates_DS"),1)

    Please Mark This As Answer if it helps to solve the issue

    • Marked as answer by Lenoj Wednesday, July 9, 2014 1:39 AM
    Tuesday, July 8, 2014 10:02 AM
  • Hi Lenoj,

    If any divide by Zero condition is coming then we need to avoid it by using IIF/SWITCH function, You can set value Zero(0) if divide by zero condition comes.

    Thanks,

    Vishal Jharwade

    Tuesday, July 8, 2014 4:55 PM
  • Thank you very much guys for the prompt reply and also for the codes. Its already working.
    Wednesday, July 9, 2014 1:39 AM