上位 10 件の合計によるグラフ ビルダーの棒グラフ フィルター積み上げ横棒グラフがあり、Y 軸カテゴリごとに上位 10 個の合計だけに制限したいと考えています。
データには、1 年分の顧客注文があります。各行は、顧客、値、および顧客の国 (その他のデータの中でも) を持つ注文品目です。x 軸は、注文値の要約統計合計です。Y 軸は顧客名です。また、スタッキング (オーバーレイ) はお客様の国によって異なります。
私の目標は、1,000 人の顧客すべてを表示するのではなく、注文額の合計で上位 10 位のみを表示することです。
現時点でのスクリプトは次のようになります。はお客様の国です
Graph Builder(
Size( 905, 603 ),
Variables(
X( :Total Dollars Ordered ),
Y(
:Customer,
Order By( :Total Dollars Ordered, Ascending, Order Statistic( "Sum" ) )
),
Overlay( :Sales Organization Code )
),
Elements(
Bar( X, Y, Legend( 4 ), Bar Style( "Stacked" ), Summary Statistic( "Sum" ) )
),
SendToReport(
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text( "Total Dollars Ordered by Customer" )}
)
)
)Re: 上位 10 の合計によるグラフ ビルダー棒グラフ フィルターこれが私が最終的に行ったものです。ご協力ありがとうございました。
トップ20は見栄えが良くなりました。
names default to here(1);
dt=current data table();
//Summarize the Total Dollars Ordered by Customer
dtSum = dt << Summary(
Group( :Customer ),
Sum( :Total Dollars Ordered ),
Freq( "None" ),
Weight( "None" ),
statistics column name format( "column" ),
Link to original data table( 0 )
);
//Sort the new data table
dtSum << sort( by(:Total Dollars Ordered), order(descending),replace table(1));
//Add Customer Sales Rank
//because the data is sorted the rank is the row number
dtSum << New Column("Customer Sales Rank", formula(Row()));
dtSum:Customer Sales Rank << delete property("formula");
dtSum << delete columns({"Total Dollars Ordered", "N Rows"});
//add the Customer Sales Rank back to the original data table
dt << Update(
With( dtSum ) ,
Match Columns( :Customer == :Customer )
);
//close the helper table
close(dtSum);
//Create the graph, horizontal bar graph, highest sales at the top,
dt << Graph Builder(
Size( 966, 804 ),
//hide the control panel
Show Control Panel( 0 ),
Variables(
X( :Total Dollars Ordered ),
Y(
:Customer,
Order By( :Total Dollars Ordered, Ascending, Order Statistic( "Sum" ) )
),
Overlay( :Sales Organization Code )
),
Elements(
Bar(
X,
Y,
Legend( 4 ),
Bar Style( "Stacked" ),
Summary Statistic( "Sum" ),
Label( "Label by Percent of Total Values" )
)
),
Local Data Filter(
//hide the local filer
Close Outline(1),
Add Filter(
columns( :Customer Sales Rank ),
Where( :Customer Sales Rank >= 1 & :Customer Sales Rank <= 20 )
)
),
SendToReport(
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text( "Total Dollars Ordered by Customer" )}
)
)
)Re: 上位 10 件の合計によるグラフ ビルダーの棒グラフ フィルターおっと....私のエラー....あなたがそれを見つけてよかったです!
Re: 上位 10 の合計によるグラフ ビルダー棒グラフ フィルター問題は「==」です。「=」が 1 つだけ必要ですRe: 上位 10 の合計によるグラフ ビルダー棒グラフ フィルター私は2番目のアプローチが好きです。スクリプトは、コードの最初のセクションの直後に停止しているようです。
dtSum == dt << Summary(
Group( :Customer ),
Sum( :Total Dollars Ordered ),
Freq( "None" ),
Weight( "None" ),
statistics column name format( "column" ),
Link to original data table( 0 )
);
新しいデータ テーブルを取得していますが、並べ替えられておらず、ランクがないためです。 JSLの次のセットです。
Re: 上位 10 の合計によるグラフ ビルダー棒グラフ フィルター上位 10 位以内の顧客だけを含む新しいデータ テーブルを作成することをお勧めします。以下のスクリプトはサブセットを生成し、データをプロットします。
names default to here(1);
dt=current data table();
dtSum == dt << Summary(
Group( :Customer ),
Sum( :Total Dollars Ordered ),
Freq( "None" ),
Weight( "None" ),
statistics column name format( "column" )
);
dtSum << sort( by(:Total Dollars Ordered), order(descending),replace table(1));
dtSum << select where(Row()>10);
dtSum << delete rows;
dtFinal = dt<< Join(
With( dtSum ),
By Matching Columns( :Customer = :Customer ),
Drop multiples( 0, 0 ),
Include Nonmatches( 0, 0 ),
Preserve main table order( 1 )
);
dtFinal << Graph Builder(
Size( 905, 603 ),
Variables(
X( :Total Dollars Ordered ),
Y(
:Customer,
Order By( :Total Dollars Ordered, Ascending, Order Statistic( "Sum" ) )
),
Overlay( :Sales Organization Code )
),
Elements(
Bar( X, Y, Legend( 4 ), Bar Style( "Stacked" ), Summary Statistic( "Sum" ) )
),
SendToReport(
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text( "Total Dollars Ordered by Customer" )}
)
)
);
私はあなたのデータのコピーを持っていなかったので、スクリプトを完全にはテストしていませんが、動作するはずです。
また、スクリプトを変更して集計テーブルの注文番号を作成し、それを元のデータ テーブルに結合し、それをローカル データ フィルターで使用して注文を選択できるようにすることもできます。
以下は、ローカル データ フィルターを使用してチャートを作成する方法の概算であるスクリプトです。
names default to here(1);
dt=current data table();
dtSum == dt << Summary(
Group( :Customer ),
Sum( :Total Dollars Ordered ),
Freq( "None" ),
Weight( "None" ),
statistics column name format( "column" ),
Link to original data table( 0 )
);
dtSum << sort( by(:Total Dollars Ordered), order(descending),replace table(1));
dtSum << New Column("Rank", formula(Row()));
dtSum:Rank << delete property("formula");
dtSum << delete columns({"Total Dollars Ordered", "N Rows"})
dt<< Update(
With( dtSum ) ,
Match Columns( :Customer == :Customer )
);
dt << Graph Builder(
Size( 905, 603 ),
Variables(
X( :Total Dollars Ordered ),
Y(
:Customer,
Order By( :Total Dollars Ordered, Ascending, Order Statistic( "Sum" ) )
),
Overlay( :Sales Organization Code )
),
Elements(
Bar( X, Y, Legend( 4 ), Bar Style( "Stacked" ), Summary Statistic( "Sum" ) )
),
SendToReport(
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text( "Total Dollars Ordered by Customer" )}
)
),
Local Data Filter(
Add Filter( columns( :Rank ), Where( :Rank >= 1 & :Rank <= 11 ) )
);