Unable to use TransformMissing to fill missing data with data from another column

Suppose I have the following table:

tab1 = Tabular[ 
  {    {"001", , 2, 3}, {"002", 4, 5, 6}, {"003", , 6, 7}, {"004", 8, 
    9, 10}, {"005", 8, 9, 11}, {"006", 8, 6, 10} },
   {"ID", "num1", "num2", "num3"}  ]

I simply want to complete the missing numbers in column “num1” with the values in column “num2”
I did something like this:

TransformMissing[  tab1, "num1" -> {#num2}  ]

But didn’t work.
I also tried:

TransformColumns[  tab1, 
 "num4" -> Function[  If[  MissingQ[#"num1"], "a", #"num1"   ]  ]
 ]

It didn’t work either.
Any suggestions?

In Mathematica, “missing” usually refers to an expression with head Missing. In an expression like {"001", , 2, 3}, no elements match Missing (which you can check with MissingQ /@ {"001", , 2, 3}. The second element of {"001", , 2, 3} is actually Null. You could transform each Null to Misssing[], but I actually don’t think that will help you here. I don’t use Tabular much, so I could be wrong, but the documentation for TransformMissing looks like it can only reference other items in the same column, not the same row.

But you can use TransformColumns like this:

TransformColumns[tab1, "num1" -> (If[Null === #num1, #num2, #num1] &)]

Thank you Eric. My actual table is very large and has a lot of missing values. I tried TransformColumns the way you put it, but didn’t work :frowning:

Show me one row from your data.

I am attaching some rows of the data

◔

Great! And you do have Missing elements. Now, what’s the rule you want to use to transform the missing items?

I want to replace missing Lat and Long with coordenadas_y and coordenadas_x

This works for me (assign your tabular data to the symbol example):

TransformColumns[
  example, 
  {"Lat" -> (If[MissingQ[#Lat], #"coordenadas_y", #Lat] &), 
   "Long" -> (If[MissingQ[#Long], #"coordenadas_x", #Long] &)}]

Your data had actual Missing items in it, so I’m using MissingQ instead of comparing to Null.

Yes!!! It works.
Thank you very much Eric.
I was doing something similar, but somehow I didn’t manage to make it work.