この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

日付ピッカーおよび静的日付のバインド

選択バインドを使用して、日付ピッカーレンズまたは静的な絶対/相対日付ステップから日付のレンズを絞り込むことができます。

次の例に、別のクエリおよび静的な相対日付ステップを絞り込む日付ピッカーレンズを別のクエリにバインドする方法を示します。

コンパクトおよび SAQL クエリへの日付ピッカーのバインド

この例では、日付ピッカーレンズで selection() バインドを使用して時間グラフレンズを絞り込みます。日付ピッカーのレンズは、次のとおりです。

1"step_for_datePicker": {
2						"type": "aggregate",
3						"datasets": "opp",
4						"query": {
5							"groups": [
6								[
7									"CloseDate_Year",
8									"CloseDate_Month"
9								]
10							],
11							"measures": [
12								[
13									"count",
14									"*"
15								]
16							],
17							"limit": 50
18						},
19						"start": [
20							[
21								[
22									"year",
23									-3
24								],
25								[
26									"year",
27									1
28								]
29							]
30						]
31					},

日付ピッカーの選択内容によって別のレンズを絞り込むには、次のコードをコンパクトまたは SAQL ステップに追加します。

1{{selection(step_for_datePicker)}}

コンパクトフォームは次のようになります。

1"step_compact_filtered_by_date_saql": {
2						"type": "aggregate",
3						"datasets": "OpportunityWithAccount",
4						"query": {
5							"groups": [
6								[
7									"CloseDate_Year",
8									"CloseDate_Month"
9								]
10							],
11							"measures": [
12								[
13									"count",
14									"*"
15								]
16							],
17							"filters": [
18								[
19									"CloseDate",
20									"{{ selection(step_for_datePicker) }}"
21								]
22							],
23							"limit": 50
24						}
25					}

SAQL は次のようになります。

1"step_date_saql_binding": {
2						"type": "aggregate",
3						"query": {
4							"pigql": "q = load \"OpportunityWithAccount\";\nq = filter q by date('CloseDate_Year', 'CloseDate_Month', 'CloseDate_Day') in {{selection(step_for_datePicker)}};\nq = group q by ('CloseDate_Year', 'CloseDate_Month');\nq = foreach q generate 'CloseDate_Year' + \"~~~\" + 'CloseDate_Month' as 'CloseDate_Year~~~CloseDate_Month', count() as 'count';\nq = limit q 2000;",
5							"groups": [
6								[
7									"CloseDate_Year",
8									"CloseDate_Month"
9								]
10							],
11							"measures": [
12								[
13									"count",
14									"*"
15								]
16							]
17						},
18						"isFacet": false,
19						"useGlobal": true
20					}
21				}

選択内容で絞り込まれる日付ディメンション (この例では "CloseDate") は、日付ピッカーレンズ"groups" で使用されるディメンションと同じ名前である必要があります。

メモ

他のコンパクトまたは SAQL レンズを絞り込むための静的日付リストセレクタのバインド

この例では、定義済みの日付範囲のリストまたは切り替えレンズの選択内容によって、ダッシュボードで別のレンズを絞り込みます。次のサンプルでは、コンパクトフォーム ("compact_step_faceted_by_static") または SAQL ("saql_step_faceted_by_static") で静的切り替えボタンレンズ ("step_date_static_with_start") から棒グラフレンズにバインドする selection() を示します。各値は、5 年前 ("year", -5)、今年 ("year", 0) までなど、相対的な日付範囲です。

1"step_date_static_with_start": {
2						"type": "static",
3						"values": [
4							{
5								"display": "-6 years",
6								"value": [
7									[
8										[
9											"year",
10											-6
11										],
12										[
13											"year",
14											0
15										]
16									]
17								]
18							},
19							{
20								"display": "-5 years",
21								"value": [
22									[
23										[
24											"year",
25											-5
26										],
27										[
28											"year",
29											0
30										]
31									]
32								]
33							},
34							{
35								"display": "-4 years",
36								"value": [
37									[
38										[
39											"year",
40											-4
41										],
42										[
43											"year",
44											0
45										]
46									]
47								]
48							}
49						],
50						"selectMode": "singlerequired",
51						"start": [
52							[
53								[
54									[
55										"year",
56										-5
57									],
58									[
59										"year",
60										0
61									]
62								]
63							]
64						]
65					}

次に、上記のサンプルで selection() バインドを使用して、選択内容で別のコンパクトまたは SAQL ステップを絞り込むことができます。

1{{selection(step_date_static_with_start)}}

コンパクトフォームは次のようになります。

1"compact_step_faceted_by_static": {
2						"type": "aggregate",
3						"datasets": "opp",
4						"query": {
5							"groups": [
6								"Product"
7							],
8							"filters": [
9								[
10									"CreatedDate",
11									"{{selection(step_date_static_with_start)}}"
12								]
13							],
14							"measures": [
15								[
16									"sum",
17									"Amount"
18								]
19							],
20							"limit": 2000
21						},
22						"isFacet": false
23					}

SAQL 選択バインドは次のようになります。

1"saql_step_faceted_by_static": {
2						"type": "aggregate",
3						"query": {
4							"pigql": "q = load \"opp\";\nq = filter q by date('CreatedDate_Year', 'CreatedDate_Month', 'CreatedDate_Day') in {{selection(step_date_static_with_start)}};\nq = group q by 'Product';\nq = foreach q generate 'Product' as 'Product', sum('Amount') as 'sum_Amount', count() as 'count';\nq = limit q 2000;",
5							"groups": [
6								"Product"
7							],
8							"measures": [
9								[
10									"sum",
11									"Amount"
12								]
13							]
14						},
15						"isFacet": false,
16						"useGlobal": true
17					},