你好論壇!
我想對以“Diff”開頭且值大於 0.1 或缺少值 (.) 的列中的單元格進行著色。以“Diff”開頭的列數將隨著數據集的增長而增長。 這是我到目前為止所擁有的,但隨著 # 或列的增長,從長遠來看可能不會起作用。
名稱默認為此處(1);
dt=當前數據表();
dt:Diff T00 << 顏色單元格("紅色", dt<<獲取行其中(dt:Diff T00 >= .1));
dt:Diff T01 << 顏色單元格("紅色", dt<<獲取行其中(dt:Diff T01 >= .1));
dt:Diff T02 << 顏色單元格("紅色", dt<<獲取行其中(dt:Diff T02 >= .1));
dt:Diff T03 << 顏色單元格("紅色", dt<<獲取行其中(dt:Diff T03 >= .1));
dt:Diff T04 << 顏色單元格("紅色", dt<<獲取行其中(dt:Diff T04 >= .1));
dt:Diff T05 << 顏色單元格("紅色", dt<<獲取行其中(dt:Diff T05 >= .1));
dt:Diff T06 << 顏色單元格("紅色", dt<<獲取行其中(dt:Diff T06 >= .1));
dt:Diff T07 << 顏色單元格("紅色", dt<<獲取行其中(dt:Diff T07 >= .1));
dt:Diff T08 << 顏色單元格("紅色", dt<<獲取行其中(dt:Diff T08 >= .1));
dt:Diff T09 << 顏色單元格("紅色", dt<<獲取行其中(dt:Diff T09 >= .1));
dt:Diff T10 << 顏色單元格("紅色", dt<<獲取行其中(dt:Diff T10 >= .1));

有 2 個錯誤......
1.我顛倒了我指定的If()函數的邏輯......我有“!=”,它需要是“==”。
2.顏色單元格()中的colNames引用必須引用特定的列....我的錯誤也是
我還稍微清理了你的代碼......沒什麼大不了的,
Names Default To Here( 1 );
dt1 = Open(
Pick File(),
columns(
Column( "IM#", Character, "Nominal" ),
Column( "LREQ", Numeric, "Continuous", Format( "Best", 10 ) ),
Column( "DATE/TIME", Character, "Nominal" ),
Column( "T(x)", Character, "Nominal" ),
Column( "BOARD", Numeric, "Continuous", Format( "Best", 10 ) ),
Column( "CHANNEL", Numeric, "Continuous", Format( "Best", 10 ) ),
Column( "DATA", Numeric, "Continuous", Format( "Best", 10 ) )
),
Import Settings(
End Of Line( CRLF ),
End Of Field( Tab, Comma, CSV( 0 ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
CompressNumericColumns( 0 ),
CompressCharacterColumns( 0 ),
CompressAllowListCheck( 0 ),
Labels( 1 ),
Column Names Start( 1 ),
Data Starts( 2 ),
Lines To Read( "All" ),
Year Rule( "20xx" )
)
) << Set Name( "DT1" );
Data Table( "DT1" ) << Sort(
By( :BOARD, :CHANNEL, :Name( "T(x)" ) ),
Order( Ascending, Ascending, Ascending ),
replace table
) << New Column( "T00 Value",
formula( If( :Name( "T(x)" ) == "T00", :Data, :T00 Value[Row() - 1] ) )
) << New Column( "Diff",
formula( (:Data - :T00 Value) / :T00 Value ),
Format( "Percent" )
);
dt = Data Table( "DT1" ) << Split(
Split By( :Name( "T(x)" ) ),
Split( :DATA, :Name( "Diff" ) ),
Group( :IM#, :LREQ, :BOARD, :CHANNEL ),
Remaining Columns( Drop All ),
Output Table Name( "DT2" )
);
Close( Data Table( "DT1" ), No Save );
//Names Default To Here( 1 );
//dt = Current Data Table();
colNames = dt << get column names( numeric, string );
For( i = 1, i <= N Items( colNames ), i++,
If( Left( colNames[i], 4 ) == "Diff",
Column( dt, colNames[i] ) << color cells(
"Red",
dt << get rows where( As Column( dt, colNames[i] ) >= .1 )
)
)
);
嗯……這很奇怪。 Wong 列突出顯示。 我已附上腳本和 csv。 我確實收到一條錯誤消息,指出“數據”列需要是字符類型。 但我需要它是計算的數字。
以 Diff*** > .1 ==Red 開頭的列中的值
以 Diff*** 開頭的列中的值 = 缺失值 ==Red

我認為這樣的事情會起作用
Names Default To Here( 1 );
dt = Current Data Table();
colNames = dt << get column names( numeric, string );
For( i = 1, i <= N Items( colNames ), i++,
If( Left( colNames[i], 4 ) != "Diff",
Column( dt, colNames ) << color cells( "Red", dt << get rows where( As Column( dt, colNames ) >= .1 ) )
)
);