Goal: count how many rows of a column have empty values.
Method 1 (works):
dt = CurrentDataTable();
Print(NRows(dt<<GetRowsWhere(IsMissing(dt:ColName))));
Method 2 (works):
Print(NRows(dt<<GetRowsWhere(IsMissing(dt:Name("ColName")))));
Method 3 (doesn't work):
Print(NRows(dt<<GetRowsWhere(IsMissing(Column(dt, "ColName")))));
The error returned by debugger for Method 3 is "argument should be numeric{1} in access or evaluation of 'Is Missing' , Is Missing/*###*/(Column( dt, "ColName" ))"
So, it's pretty easy to understand that referencing a column by dt:ColName is identical to dt:Name("ColName"), but I'm confused as to why Column(dt, "ColName") performs differently.
In addition, if I were to do the following:
ref1 = dt:ColName;
ref2 = dt:Name("ColName");
ref3 = Column(dt, "ColName");
Then I get ref1 and ref2 holding a single numerical value (corresponding to the first value in the column), whereas ref3 is a reference to an appropriate Column object (as I would have expected all three declarations to accomplish).
The ref1 and ref2 results seems especially odd to me -- Method #1 and #2 above were returning the correct number of empty cells in the column, so obviously in those implementation of the reference it wasn't just looking at the first value in the column. It appears what is happening is that when dt:ColName is being set to a variable, it's unacceptable to use the entirety of dt:ColName and it's instead choosing to set the variable to dt:ColName[1].
Why have this behavior? When I use ref = dt:ColName, I would expect it to either return the same column reference generated by ref = Column(dt, "ColName") or perhaps a matrix/list full of values that correspond to the contents of the column in the order in which they appear.
Essentially, my questions boil down to (1) why do these behave differently, (2) is there an easy way to identify when dt:ColName needs to be used, and when Column(dt, "ColName") needs to be used, and (3) why does ref1 = dt:CFU return a reference to the first value in the column instead of either a reference to the column itself or a fully populated matrix/list that corresponds to all values in the column?
Thanks!