Skip to main content
Solved

Using AND with Null values

  • February 8, 2025
  • 0 replies
  • 277 views

Forum|alt.badge.img+5

I have a formula with multiple Null and Not Null values, one of the nested statements needs to look at two fields so I used AND, but this generates an error "AND" cannot be applied. 

If(
IsNull([Pallet Grp "C"]),0,
((Nz([Low, Carton "C"] and (IsNull([high, carton "C"])),1)
[high, carton "C"]-[low, carton "C"]+1)

Can someone recommend a solution--if possible.

Best answer by JohnRomano

I appreciate the help, I was trying to be as direct as possible--noted for the next time. Your solution produced the desired outcome. Thank you.

MarkShnierYou
Forum|alt.badge.img+22

Sure, try this

If(
IsNull([Pallet Grp "C"]),0,
Nz([Low, Carton "C"]) and IsNull([high, carton "C"]),1,
[high, carton "C"]-[low, carton "C"]+1)


MarkShnierYou
Forum|alt.badge.img+22

My initial suggestion was incorrect, but maybe this is what you want.  But I think it would help if you said in plain english what you want the formula to do.

Also when you are evaluating numeric fields to tell if they are null, it requires that field's properties to have the checkbox "treat blank as zero" deselected.

If(
IsNull([Pallet Grp "C"]),0,
Nz([Low, Carton "C"])=0 and IsNull([high, carton "C"]),1,
[high, carton "C"]-[low, carton "C"]+1)