转置数据表后,
Data Table( "Overall" ) << Transpose(
columns( :Value),
By( :Department, :Resource, :Chart ),
Label( :Date),
Output Table( "report overall" )
);
我的按日期显示的标题不再按顺序排列。我必须手动拖放才能修复它。幸运的是,它只涉及 7-8 列。尽管如此,这样做还是浪费了我的时间,而我最初并不需要这样做。

有没有办法让它按照图中所示的顺序排列?

由于我的固定日期范围是 7 天,因此这些日期每天都会变化。
set_date = Today();
date_min = (set_date - In Days(7));
Data Table("Overall") << Select where (:date < date_min) << Delete Rows;
这是一个脚本,它将按照您的要求重新排列列
Names Default To Here( 1 );
// Example table to use for illustration
New Table( "Example",
Add Rows( 0 ),
New Column( "Department", Character, "Nominal" ),
New Column( "Resource", Character, "Nominal" ),
New Column( "Chart", Character, "Nominal", Set Selected ),
New Column( "17/10/2024", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "16/10/2024", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "15/10/2024", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "11/10/2024", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "14/10/2024", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "18/10/2024", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "13/10/2024", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "12/10/2024", Numeric, "Continuous", Format( "Best", 12 ) )
);
Wait( 5 );
// This JSL with properly reorder the data table
dt = Current Data Table();
colNames = dt << get column names( string );
For Each( {col}, colNames,
If( Is Missing( Try( Num( Informat( col, "d/m/y" ) ) ) ) == 0,
Column( dt, col ) << set name( Char( Num( Informat( col, "d/m/y" ) ) ) ),
Column( dt, col ) << set name( "0" || col )
)
);
// Reorder columns by name
dt << Reorder by Name;
colNames = dt << get column names( string );
For Each( {col}, colNames,
If( Is Missing( Num( col ) ) == 0,
Column( dt, col ) << set name( Format( Num( col ), "d/m/y" ) ),
Column( dt, col ) << set name( Substr( col, 2 ) )
)
);