-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorder_items.view.lkml
147 lines (122 loc) · 3.37 KB
/
order_items.view.lkml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
view: order_items {
sql_table_name: demo_db.order_items ;;
dimension: id {
primary_key: yes
type: number
sql: ${TABLE}.id ;;
}
dimension: inventory_item_id {
type: number
hidden: yes
sql: ${TABLE}.inventory_item_id ;;
}
dimension: order_id {
type: number
hidden: no
sql: ${TABLE}.order_id ;;
}
measure: bigger_number {
type: number
sql: ${commas}*1000 ;;
value_format: "0"
drill_fields: [commas,returned_date,inventory_item_id]
}
measure: commas {
type: count_distinct
sql: ${id},${inventory_item_id},${sale_price} ;;
}
measure: inventory_count {
type: count_distinct
sql: ${inventory_item_id} ;;
}
dimension_group: returned {
label: "A1"
type: time
timeframes: [
raw,
time,
date,
week,
month,
quarter,
year
]
sql: ${TABLE}.returned_at ;;
}
dimension: dummy_two {
label: "A1 Month"
case: {
when: {
label: "Highest Priced Item"
sql: 1=1 ;;
}
when: {
label: "Average Price"
sql: 1=1 ;;
}
}
}
dimension: sale_price {
type: number
sql: ${TABLE}.sale_price ;;
value_format: "$0.00"
}
dimension: returned_flag {
type: yesno
sql: ${returned_date} IS NOT NULL ;;
}
dimension: yesno_count {
type: number
sql: CASE WHEN ${returned_date} THEN (SELECT COUNT(*) FROM demo_db.order_items WHERE ${returned_flag})
ELSE (SELECT COUNT(*) FROM demo_db.order_items WHERE NOT ${returned_flag}) END;;
}
measure: return_rate {
type: average
sql: CASE WHEN ${returned_raw} IS NULL THEN 0 ELSE 1 END ;;
value_format: "0.00%"
}
measure: count {
type: count
drill_fields: [id, inventory_items.id, orders.id]
}
measure: min_price {
label: "Lowest Priced Item"
description: "The lowest item price of all the order items in the grouping"
type: min
sql: ${sale_price} ;;
value_format: "$0.00"
drill_fields: [id, products.id, products.item_name, returned_flag, sale_price]
}
measure: max_price {
label: "Highest Priced Item"
description: "The highest price of all the order items in the grouping"
type: max
sql: ${sale_price} ;;
value_format: "$#,##0.00"
drill_fields: [id, products.id, products.item_name, returned_flag, sale_price]
}
measure: total_price {
type: sum
sql: ${sale_price} ;;
value_format: "$#,##0.00"
drill_fields: [id, products.id, products.item_name, returned_flag, sale_price]
}
measure: big_ass_number {
type: number
sql: ${total_price}*100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ;;
}
measure: average_price {
type: average
sql: ${sale_price} ;;
value_format: "$#,##0.00"
drill_fields: [id, products.id, products.item_name, returned_flag, sale_price]
}
measure: price_range {
label: "Range of Prices"
description: "The difference between the lowest and highest priced item in the grouping"
type: number
sql: ${max_price} - ${min_price} ;;
value_format: "$#,##0.00"
drill_fields: [id, products.id, products.item_name, returned_flag, sale_price]
}
}