排序依據

Essbase Report Writer ORDERBY 命令會根據指定欄中的資料值排序報表中的列。

語法

<ORDERBY ( [<rowgroupDimension>,] <column> [<direction>]{,<column> [<direction>]})

參數

< 選擇性列群組維度 >

決定要作為集合排序之資料列的資料列群組維度。

< 資料欄 >

@DATACOLUMN (<colnumber>) | @DATACOLUMN (<colnumber>)

其中 <colnumber> 是目標資料欄編號;必須介於 1 與報表中的資料欄數目上限之間。

< 方向 >

您可以指定多個具有不同排序方向的資料欄,其中:

  • ASC 是遞增排序

  • DESC 是遞減排序

注意

您可以在相同的報表指令碼中使用 ORDERBY、TOP、BOTTOM 和 RESTRICT,但每個指令只能使用一次。如果您在同一報表指令集中的第二個報表中重複相同的指令,第二個指令會覆寫第一個指令。將全域指令碼格式指令 (例如 SAVEROW) 置於 PAGE、COLUMN 指令或相關成員之前 (例如 <ICHILDREN 或 <IDESCENDANTS)。

如果報表指令集中存在任何 ORDERBY、TOP、BOTTOM 或 RESTRICT 指令,則列群組維度 <rowgroupDimension> 應相同。此限制會移除資料列群組內資料列排序與排序的任何混淆。否則,會發出錯誤。

如果具有 ORDERBY 的相同報表中有 TOP 或 BOTTOM 命令,則 ORDERBY 的排序資料欄不需要與 TOP 或 BOTTOM 的順序資料欄相同。

ORDERBY、TOP 和 BOTTOM 命令會依報表輸出的資料值排序報表輸出。RESTRICT 指令會限制報表輸出的有效列數。它們的執行順序是:

  1. 排序成員名稱的任何排序指令 (例如 <SORTDESC 或 <SORTASC)

  2. 限制

  3. TOP 與底端

  4. 排序依據

此執行順序會套用,無論指令在報表指令碼中的顯示順序為何。

如需同時使用 TOP、BOTTOM、ORDERBY 和 RESTRICT 的範例,請參閱 BOTTOM 指令的項目。

預設值

最內部的資料列群組是預設的資料列群組維度。預設方向為遞增。

範例

下列報表命令檔是針對圖庫中可用的「基本範例」立方體所設計。

//Page dimension 
<PAGE("Measures")

//Column dimensions
<COLUMN("Scenario", "Year")

//Row dimensions
<ROW("Market", "Product")

// Page Members
"Sales"

// Column Members
"Scenario" 

"Jan" "Feb" "Mar" 

// Row Members
"New York"

"Product" "100" "100-10" "100-20" "100-30" "200" "200-10" "200-20" "200-30" "200-40" "300" "300-10" "300-20" "300-30" "400" "400-10" "400-20" "400-30" "Diet" "100-20" "200-20" "300-30" 

// Data sorting
<ORDERBY ("Product", @DATACOLUMN(1) ASC, @DATACOLUMN(2) DESC, @DATACOLUMN(3) ASC) 
!
// End of report

上述報表指令碼會產生下列報表:

                                        Sales Scenario 

                                       Jan      Feb      Mar 
                                  ======== ======== ======== 

New York         100-20           #Missing #Missing #Missing 
                 100-30           #Missing #Missing #Missing 
                 200-20           #Missing #Missing #Missing 
                 200-30           #Missing #Missing #Missing 
                 300-30           #Missing #Missing #Missing 
                   Diet           #Missing #Missing #Missing 
                 200-10                 61       61       63 
                 400-30                134      189      198 
                 300-20                180      180      182 
                 400-20                219      243      213 
                 400-10                234      232      234 
                 300-10                483      495      513 
                 200-40                490      580      523 
                   200                 551      641      586 
                   400                 587      664      645 
                   300                 663      675      695 
                 100-10                678      645      675 
                   100                 678      645      675 
                     Product         2,479    2,625    2,601