Skip to main content
spelling cleanup
Source Link
gnat
  • 20.5k
  • 29
  • 117
  • 310

If the oldvalueold value is nullthenull the result of the equations should rightly be null. This is becasuebecause null is not a number, it means unknown value. Therefore the calcaluationcalculation cannot proceed.

Of course your equation also fails if oldvalue = 0old value = 0 as you cannot divide by zero.

Typically you handle these things with a case statmentstatement that will take you the path of what you want to show. So if you want the result to show as null when you can't calculate (as with a null or a zero, then you would do a case statmentstatement something like

case when [oldvalue][old value] = 0 then null else 100 * (([old value] - [new value]) /[old value]) end 

If the oldvalue is nullthe result of the equations should rightly be null. This is becasue null is not a number, it means unknown value. Therefore the calcaluation cannot proceed.

Of course your equation also fails if oldvalue = 0 as you cannot divide by zero.

Typically you handle these things with a case statment that will take you the path of what you want to show. So if you want the result to show as null when you can't calculate (as with a null or a zero, then you would do a case statment something like

case when [oldvalue] = 0 then null else 100 * (([old value] - [new value]) /[old value]) end 

If the old value is null the result of the equations should rightly be null. This is because null is not a number, it means unknown value. Therefore the calculation cannot proceed.

Of course your equation also fails if old value = 0 as you cannot divide by zero.

Typically you handle these things with a case statement that will take you the path of what you want to show. So if you want the result to show as null when you can't calculate (as with a null or a zero, then you would do a case statement something like

case when [old value] = 0 then null else 100 * (([old value] - [new value]) /[old value]) end 
Post Made Community Wiki by Vasiliy Sharapov
Source Link
HLGEM
  • 28.8k
  • 4
  • 70
  • 116

If the oldvalue is nullthe result of the equations should rightly be null. This is becasue null is not a number, it means unknown value. Therefore the calcaluation cannot proceed.

Of course your equation also fails if oldvalue = 0 as you cannot divide by zero.

Typically you handle these things with a case statment that will take you the path of what you want to show. So if you want the result to show as null when you can't calculate (as with a null or a zero, then you would do a case statment something like

case when [oldvalue] = 0 then null else 100 * (([old value] - [new value]) /[old value]) end