This python function implements the logic you described in your question: def calculate_X(A,B,C,D): if A == 0 and B == 0: X = calculation_1(A,B,C,D) elif A == 0: X = calculation_2(A,B,C,D) elif B == 0: X = calculation_3(A,B,C,D) else: X = calculation_4(A,B,C,D) return X Then access the function using the expression calculate_X(!A!, !B!, !C!, !D!) --- The `if` and `elif` conditions are tested in order from top to bottom, so there is no need to explicitly test e.g `A == 0 and B != 0` for `calculation_2` instead of just `A == 0`, because it is already certain at that point that `A == 0 and B == 0` if False