0
=iif(Sum(Fields!ClsRead.Value)-Sum(Fields!OpnRead.Value)=0,"NO HSD Supplied",sum(Fields!HSDIssued.Value)/(Sum(Fields!ClsRead.Value)-Sum(Fields!OpnRead.Value)))
Maciej Los
  • 8,468
  • 1
  • 20
  • 35
  • 1
    Can you be more specific and provide more details about your issue? What's error message? – Maciej Los Oct 23 '20 at 07:48
  • @MaciejLos Hey, this expression is basically to calculate average petrol consumption. i am trying to write an expression when ever the difference between open reading and close reading is 0 it must return NO HSD SUPPLIED else if it not 0 then calculate average. –  Oct 23 '20 at 07:55

1 Answers1

2

Using IIf you have to remember that both side (TruePart and FalsePart) are always evaluated so dividing by 0 raise an #Error.

You can use custom code (right click design surface outside report > Report Properties > Code) and replace IIf with an If/Then/Else.

tezzo
  • 10,858
  • 1
  • 25
  • 48