...
概要
Wiki Markup |
---|
{html}<iframe width="700" height="394" src="https://www.youtube.com/embed/1O7ogaEZ4p0?color=white" frameborder="0" allowfullscreen></iframe>{html} |
Introduction
In this tutorial, we will walk through setting up a Union sub query. A good way to think about Unions is - use them if you need to combine multiple fields into the one column, either from the same or different views or sources.
In this scenario our main report will have a list of invoicing figures by region, we will then use the Union query to display negative cost figures in the same column, and then add sub totals to see the total income for each region.
Master Query
The Master Query is going to include:
...
はじめに
このチュートリアルでは、結合サブクエリーの設定を段階的に説明します。結合は、同じまたは異なるビューやソースから、複数のフィールドを1つのカラム(列)に組み合わせる必要がある場合に使用するものと考えるとよいでしょう。
このシナリオのメインレポートでは、地域別の請求額の一覧を設定します。次に、結合クエリーを使用して同じカラム(列)内にある負のコスト数値を表示した後、小計を追加して地域ごとの合計収入を確認します。
マスタークエリー
マスタークエリーには以下の項目を含めます。
- Camp Region
- 計算フィールド:"Invoiced"テキストラベル
- Sum Invoiced Amount
Union Query
...
結合クエリー
結合クエリーには以下の項目を含めます。
- Camp Region
- Calculated Field: 計算フィールド:"Cost" text labelCalculated Field: Sum テキストラベル
- 計算フィールド:Sum Cost*-1 (to convert the Cost figures to a negative value)
...
- 1(コスト数値を負の値に変換します)
初期化
Section |
---|
Column |
---|
| 1. Click on the Create link and select Report to begin building your report. 「作成」リンクをクリックして、「レポート」を選択しレポートの作成を開始します。 |
Column |
---|
|
|
|
Section |
---|
Column |
---|
| 2. You should now be on the Initialise Report page. Select the Drag and Drop Builder as the build tool. 「新規レポート作成」ページが表示されます。レポートの作成方法として、「ドラッグ&ドロップビルダー」を選択します。 |
Column |
---|
|
|
|
Section |
---|
Column |
---|
| 3. Select ビューとして「Ski Team as the View.」を選択します。 |
Column |
---|
|
|
|
...
マスタークエリー
Section |
---|
Column |
---|
| 4. Drag and drop the 「 Camp Region dimension and 」ディメンションおよび「 Invoiced Amount metric into the Columns list.」メトリックを「カラム(列)」一覧にドラッグ&ドロップします。 |
Column |
---|
|
|
|
Label Field
...
ラベルフィールド
マスタークエリーを完了するには、ラベルフィールドが必要となります。このフィールドは、マスタークエリーのロウ(行)を"Invoiced"ロウ(行)として識別するために使用されます。結合クエリーで同様の計算が行われ、"Cost"としてロウ(行)が識別されます。
Section |
---|
Column |
---|
| 5. Click on the + to create a calculated field, in the bottom of the View Fields List panel. ビューフィールド一覧パネルの下部で「+」をクリックし、計算フィールドを作成します。 |
Column |
---|
|
|
|
Section |
---|
Column |
---|
| 6. Set the Calculated Field Name to Label Note: the name for this field can be anything, it will not change the way the union works if it's called something else.7. Type Invoiced into the text box under the main calculation panel, as shown here, and click + Add to add it to the calculation.「計算フィールド名」をLabelに設定します。 注意:このフィールドの名前は任意です。名前が変更されても結合の処理方法は変更されません。 7. ここで示すように、メイン計算パネルでテキストボックスにInvoicedと入力し、「+追加」をクリックして計算式に追加します。 |
Column |
---|
|
|
|
Section |
---|
Column |
---|
| 8. Click the Validate button to ensure your calculation is built correctly.9. Click the Save button to complete your calculation.「テスト」ボタンをクリックして、計算式が正しく作成されていることを確認します。 9. 「保存」ボタンをクリックして、計算式を完了します。 |
Column |
---|
|
|
|
Section |
---|
Column |
---|
| 10. Drag the Label calculation to between the 「カラム(列)」一覧または「表のプレビュー」のどちらかで、計算フィールドの「Label」を、「Camp Region and 」と「Sum Invoiced Amount fields in either the Columns list or Table Preview.」のフィールドの間にドラッグします。 |
Column |
---|
|
|
|
...
結合クエリー
...
結合の作成
Section |
---|
Column |
---|
| 11. Click on the + button in the Sub Query panel to the left of the Data step to add a Sub Query. 12. Set the Type to Union and Style to Basic. 13. Click Ok to set up the query.「データ」ステップの左側にある「サブクエリー」パネルで「+」ボタンをクリックし、サブクエリーを追加します。 12.「タイプ」を「結合」に、「スタイル」を「基本」に設定します。 13. 「OK」をクリックしてクエリーを設定します。 |
Column |
---|
|
|
|
Calculations
To complete the union query, two calculations will be required;
- Label: this will be used to identify the rows from the union query as "Cost" rows. There will be a similar calculation in the master query to identify rows as "Invoiced".
- Cost: this will be used to convert the cost figure to a negative value. This will mean that when a sub total is added to the report, the cost amount will be subtracted from the invoiced amount.
...
計算
結合クエリーを完了するには、2つの計算が必要となります。
- Label:結合クエリーのロウ(行)を"Cost"ロウ(行)として識別するために使用されます。マスタークエリーで同様の計算が行われ、"Invoiced"としてロウ(行)が識別されます。
- Cost:コスト数値を負の値に変換するために使用されます。つまり、小計がレポートに追加されると、コスト金額が請求金額から差し引かれます。
ラベル
Section |
---|
Column |
---|
| 14. Click on the + to create a calculated field, in the bottom of the View Fields List panel. ビューフィールド一覧パネルの下部で「+」をクリックし、計算フィールドを作成します。 |
Column |
---|
|
|
|
Section |
---|
Column |
---|
| 15. Set the Calculated Field Name to Label Note: the name for this field can be anything, it will not change the way the union works if it's called something else. 16. Type Cost into the text box under the main calculation panel, as shown here, and click + Add to add it to the calculation. 17. Click the Validate button to ensure your calculation is built correctly. 18. Click the Save button to complete your calculation.「計算フィールド名」をLabelに設定します。 注意:このフィールドの名前は任意です。名前が変更されても結合の処理方法は変更されません。 16. ここで示すように、メイン計算パネルでテキストボックスにCostと入力し、「+追加」をクリックして計算式に追加します。 17. 「テスト」ボタンをクリックして、計算式が正しく作成されたことを確認します。 18. 「保存」ボタンをクリックして、計算式を完了します。 |
Column |
---|
|
|
|
Cost
Section |
---|
Column |
---|
| 19. Click on the + to create a calculated field, in the bottom of the View Fields List panel. 20. Set the Calculated Field Name to Cost Note: the name for this field can be anything, it will not change the way the union works if it's called something else. 21. Click on the ∑ button. 22. Select the Camp Cost field from the Select Field drop down, and click + Add. 23. Close the bracket by clicking ). 24. Click the * button to multiply the field by a value. 25. Type -1 into the text entry field, and click + Add to put in your calculation. 26. Click the Validate button to ensure your calculation is built correctly. 27. Click the Save button to complete your calculation.ビューフィールド一覧パネルの下部で「+」をクリックし、計算フィールドを作成します。 20. 「計算フィールド名」をCostに設定します。 注意;このフィールドの名前は任意です。名前が変更されても結合の処理方法は変更されません。 21. 「∑」ボタンをクリックします。 22. 「フィールドを選択」ドロップダウンから「Camp Cost」フィールドを選択し、「+追加」をクリックします。 23. 「)」をクリックしてカッコを閉じます。 24. 値でフィールドを乗算するには、「*」ボタンをクリックします。 25. テキスト入力フィールドに-1と入力して、「+追加」をクリックして計算式に追加します。 26. 「テスト」ボタンをクリックして、計算式が正しく作成されたことを確認します。 27. 「保存」ボタンをクリックして、計算式を完了します。 |
Column |
---|
|
|
|
...
結合の設定
Section |
---|
Column |
---|
| 28. Drag the Camp Region field into the Sub Query Fields list, directly next to the Camp Region field in the Master Query Fields list. 29. Drag the Label calculated field into the Sub Query Fields list, directly next to the Label field in the Master Query Fields list. 30. Drag the Cost calculated field into the Sub Query Fields list, directly next to the Sum Invoiced Amount field in the Master Query Fields list. 31. Change the name of the Sub Query to Cost and click Save to complete the Union.「マスタークエリーフィールド」一覧の「Camp Region」フィールドのすぐ横にくるように、「Camp Region」フィールドを「サブクエリーフィールド」一覧にドラッグします。 29. 「マスタークエリーフィールド」一覧の「Label」フィールドのすぐ横にくるように、「Label」計算フィールドを「サブクエリーフィールド」一覧にドラッグします。 30. 「マスタークエリーフィールド」一覧の「Sum Invoiced Amount」フィールドのすぐ横にくるように、「Cost」計算フィールドを「サブクエリーフィールド」一覧にドラッグします。 31. サブクエリーの名前をCostに変更して、「保存」をクリックして結合を完了します。 |
Column |
---|
|
|
|
...
設定の編集
Section |
---|
Column |
---|
| 32. If you need to make changes to your sub query setup at all, click the Edit Settings link. クエリー設定を変更する必要がある場合は、「設定の編集」リンクをクリックします。 |
Column |
---|
|
|
|
...
書式
Section |
---|
Column |
---|
| 33. Click on the 「Sun Invoiced Amount field's drop down list and apply a Sum Total」フィールドのドロップダウンリストをクリックして、「集約の合計」を適用します。 |
Column |
---|
|
|
|
Section |
---|
Column |
---|
| 34. Click on the Camp Region field's drop down list and select Format. You could also select the Column Formatting menu from the main navigation bar.35. Enable the Suppress Duplicates option. This will make the final table easier to read, with the inclusion of sub totals.「Camp Region」フィールドのドロップダウンリストをクリックして、「書式」を選択します。メインナビゲーションバーから、「カラム(列)の書式」メニューを選択することもできます。 35. 「重複表示の排除」オプションを有効化します。これにより、最終的な表に小計が組み込まれて、表がより読みやすくなります。 |
Column |
---|
|
|
|
Section |
---|
Column |
---|
| 36. While still on the Camp Region field, open the Summary settings and enable the Sub Total option. 「Camp Region」フィールドが表示されているときに、「サマリー」設定を開いて「小計」オプションを有効化します。 |
Column |
---|
|
|
|
Section |
---|
Column |
---|
| 37. While still in the Column Formatting menu, select the 「カラム(列)の書式」メニューが表示されているときに、左側の一覧から「Sum Invoiced Amount field from the list on the left.」フィールドを選択します。 36. Set the name to Value. 名前をValueに設定します。 |
Column |
---|
|
|
|
Section |
---|
Column |
---|
| 38. Close the menu. メニューを閉じます。 |
Column |
---|
|
|
|
...
保存
Section |
---|
Column |
---|
| 39. Click Report > Save to activate your report. 「レポート」>「保存」をクリックして、レポートを有効化します。 |
Column |
---|
|
|
|
Section |
---|
Column |
---|
| 40. Set the Name of your report to レポートの名前をUnion Sub Query Tutorial.に設定します。 41. Set the Description to 説明をThis report was written using the Sub Query Tutorial.に設定します。 42. Select Tutorial as the Category. カテゴリーとして「チュートリアル」を選択します。 43. Select Training as the Sub Category. サブカテゴリーとして「トレーニング」を選択します。 44. Click Activate to finish. 「有効化」をクリックして終了します。 |
Column |
---|
|
|
|
Section |
---|
Column |
---|
| 45. You now have an active Union Sub Query report. これで、有効化された結合サブクエリーレポートが設定されました。 |
Column |
---|
|
|
|