This expression worked for me, thanks for help if("diameter_valve" is null, overlay_nearest('waterpipe',diameter_pipe,max_distance:=0.01)[0],"diameter_valve")