-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorders.view.lkml
165 lines (143 loc) · 3.71 KB
/
orders.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
include: "users.view.lkml"
view: orders {
sql_table_name: demo_db.orders ;;
extends: [users]
parameter: test {
type: unquoted
allowed_value: {value:"\"a\""}
allowed_value: {value:"b"}
default_value: "b"
}
label: "{% if test._parameter_value == 'a' %} A
{% elsif test._parameter_value == 'b' %} B
{% else %} C {% endif %} Change in Base"
dimension: test_param {
type: string
sql: {% parameter test %} ;;
}
dimension: test_text{
type: string
sql: 1=1 ;;
html: <h1> test if this works </h1> ;;
}
dimension: id {
primary_key: yes
type: number
sql: ${TABLE}.id ;;
}
dimension_group: created {
type: time
timeframes: [
raw,
time,
date,
hour,
day_of_month,
week,
day_of_week,
day_of_week_index,
month,
month_name,
quarter,
year,
day_of_year,
fiscal_quarter,
fiscal_quarter_of_year,
second
]
sql: ${TABLE}.created_at ;;
}
dimension: periods_ago {
type: number
sql: CASE WHEN MOD(${created_year},4) = 0 THEN FLOOR( DATEDIFF(CURRENT_DATE(), ${created_raw}) / 366 )
WHEN MOD(${created_year},4) != 0 THEN FLOOR( DATEDIFF(CURRENT_DATE(), ${created_raw}) / 365 )
END;;
}
measure: first_order {
type: date_time
sql: min(${created_raw}) ;;
}
dimension: status {
type: string
sql: ${TABLE}.status ;;
}
dimension: test_string {
type: string
sql: concat(${status}, ' ', ${city}) ;;
}
dimension: user_id {
type: number
# hidden: yes
sql: ${TABLE}.user_id ;;
}
dimension: case_param_dimension {
type: string
case: {
when: {
sql: ${user_id} >= 1 AND ${user_id} < 100 ;;
label: "1 to 99"
}
when: {
sql: ${user_id} >= 100 AND ${user_id} < 200 ;;
label: "100 to 199"
}
else: "Greater than or equal to 200"
}
}
dimension: bracket {
type: tier
tiers: [0,50,100,500,1000, 10000]
style: integer
sql: ${user_id} ;;
}
measure: count_distinct_of_user_ids {
type: count_distinct
sql: ${user_id} ;;
drill_fields: [user_id]
}
measure: count_not_california {
label: "Count of Users from States other than California"
type: count
filters: {
field: state
value: "-California"
}
filters: {
field: state
value: "-Michigan"}
}
measure: count {
type: count
drill_fields: [id, users.first_name, users.last_name, users.id, order_items.count]
html: <div style="float: left
; width:{{ value | times:100}}%
; background-color: rgba(0,180,0,{{ value | times:100 }})
; text-align:left
; color: #FFFFFF
; border-radius: 5px"> <p style="margin-bottom: 0; margin-left: 4px;">{{ value | times:100 }}%</p>
</div>
<div style="float: left
; width:{{ 1| minus:value | times:100}}%
; background-color: rgba(0,180,0,0.1)
; text-align:right
; border-radius: 5px"> <p style="margin-bottom: 0; margin-left: 0px; color:rgba(0,0,0,0.0" )>{{value}}</p>
</div>
;;
}
measure: percent_complete {type: number sql: (1/100)*(${user_id});;
html: <div style="float: left
; width:{{ value | times:100}}%
; background-color: rgba(0,180,0,{{ value | times:100 }})
; text-align:left
; color: #FFFFFF
; border-radius: 5px"> <p style="margin-bottom: 0; margin-left: 4px;">{{ value | times:100 }}%</p>
</div>
<div style="float: left
; width:{{ 1| minus:value | times:100}}%
; background-color: rgba(0,180,0,0.1)
; text-align:right
; border-radius: 5px"> <p style="margin-bottom: 0; margin-left: 0px; color:rgba(0,0,0,0.0" )>{{value}}</p>
</div>
;;
}
}