Hi! What's the right way to reference a column by index? Ideally I was looking for something like this:
Thank you in advance!
Ah... I see what you want now.
Try this as your formula. It uses the format column(dt, n)[row()] to get the value in the current row, of the nth column of a data table, where the value of n is whatever you've placed in the current row of the :block column.
Column( :Block << get data table, :Block )[Row()]
Cheers,
Brady
You should be able to use just Column(index).
Send Messages to Data Column Objects
col = Column( 2 ); // assign a reference to the second column
It may be true for scripts, but in formulas I get this error:
Interestingly, the popup suggests thatthe number can be provided, but it doesn't appear to be the case
Try with << get name instead of Column Name()
Choose(:Block, Column(1) << get name, Column(2) << get name, Column(3) << get name )
Full example:
Names Default To Here(1); dt = New Table("Untitled", Add Rows(3), Compress File When Saved(1), New Column("Block", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3])), New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([1, ., .])), New Column("Column 3", Numeric, "Continuous", Format("Best", 12), Set Values([2, ., .])), New Column("Column 4", Numeric, "Continuous", Format("Best", 12), Set Values([3, ., .])), New Column("Formula", Character, "Nominal", Formula(Choose(:Block, Column(1) << get name, Column(2) << get name, Column(3) << get name)) ) );
Thank you jthi, I feel like "<< get name" gets us one step forward. My final goal is to do a HLOOKUP basically, here's a demonstration. Currently it pulls the column name, while I want it to look at the data of that column.
Here's full code if needed:
New Table( "Untitled",Add Rows( 3 ),Compress File When Saved( 1 ),New Column( "Column 1",Numeric,"Continuous",Format( "Best", 12 ),Set Values( [11, 111, 1111] )),New Column( "Column 2",Numeric,"Continuous",Format( "Best", 12 ),Set Values( [22, 222, 2222] )),New Column( "Column 3",Numeric,"Continuous",Format( "Best", 12 ),Set Values( [33, 333, 3333] )),New Column( "Block",Numeric,"Continuous",Format( "Best", 12 ),Set Values( [1, 2, 3] )),New Column( "Formula",Character,"Nominal",Formula(Choose( :Block,Column( 1 ) << get name,Column( 2 ) << get name,Column( 3 ) << get name))))
Not exactly sure what data you want to get from the columns. Does Block column define the column and row for the cell you want to get the data from?
Column(:Block)[:Block]