-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcharges.view.lkml
182 lines (154 loc) · 3.55 KB
/
charges.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
view: charges {
sql_table_name: stripe.charges ;;
## Dimensions
dimension: id {
primary_key: yes
type: string
sql: ${TABLE}.id ;;
}
dimension: amount {
type: number
sql: ${TABLE}.amount*1.0/100 ;;
value_format: "$#,##0.00"
}
dimension: amount_refunded {
type: number
sql: ${TABLE}.amount_refunded*1.0/100 ;;
value_format: "$#,##0.00"
}
dimension: captured {
type: yesno
sql: ${TABLE}.captured ;;
}
dimension_group: created {
type: time
timeframes: [time, date, week, month]
sql: ${TABLE}.created ;;
}
dimension: currency {
type: string
sql: ${TABLE}.currency ;;
}
dimension: customer_id {
type: string
# hidden: true
sql: ${TABLE}.customer_id ;;
}
dimension: dispute_id {
type: string
sql: ${TABLE}.dispute_id ;;
}
dimension: failure_code {
type: string
sql: ${TABLE}.failure_code ;;
}
dimension: invoice_id {
type: string
# hidden: true
sql: ${TABLE}.invoice_id ;;
}
dimension: paid {
type: yesno
sql: ${TABLE}.paid ;;
}
dimension_group: received {
type: time
timeframes: [time, date, week, month]
sql: ${TABLE}.received_at ;;
}
dimension: refunded {
type: yesno
sql: ${TABLE}.refunded ;;
}
dimension: status {
type: string
sql: ${TABLE}.status ;;
}
## Measures
dimension: days_until_received {
type: number
sql: datediff('days',${created_date},${received_date}) ;;
}
measure: avg_days_until_received {
type: average
sql: ${days_until_received} ;;
value_format: "#0.00"
drill_fields: [detail*]
}
measure: total_gross_amount {
type: sum
sql: ${amount} ;;
value_format: "[>=1000000]$0.00,,\"M\";[>=1000]$0.00,\"K\";$0.00"
drill_fields: [detail*]
}
measure: total_failed_charges {
type: sum
sql: ${amount} ;;
value_format: "[>=1000000]$0.00,,\"M\";[>=1000]$0.00,\"K\";$0.00"
drill_fields: [detail*]
filters: {
field: status
value: "failed"
}
}
measure: total_refunds {
type: sum
sql: ${amount_refunded} ;;
value_format: "[>=1000000]$0.00,,\"M\";[>=1000]$0.00,\"K\";$0.00"
drill_fields: [detail*]
}
measure: total_net_amount {
type: number
sql: ${total_gross_amount} - ${total_refunds} - ${total_failed_charges} ;;
value_format: "[>=1000000]$0.00,,\"M\";[>=1000]$0.00,\"K\";$0.00"
drill_fields: [detail*]
}
measure: cumulative_gross {
type: running_total
sql: ${total_gross_amount} ;;
value_format: "[>=1000000]$0.00,,\"M\";[>=1000]$0.00,\"K\";$0.00"
}
measure: cumulative_refunds {
type: running_total
sql: ${total_refunds} ;;
value_format: "[>=1000000]$0.00,,\"M\";[>=1000]$0.00,\"K\";$0.00"
}
measure: cumulative_net {
type: running_total
sql: ${total_net_amount} ;;
value_format: "[>=1000000]$0.00,,\"M\";[>=1000]$0.00,\"K\";$0.00"
}
measure: avg_charge_amount {
type: average
sql: ${amount} ;;
value_format: "[>=1000000]$0.00,,\"M\";[>=1000]$0.00,\"K\";$0.00"
}
measure: charge_count {
type: count
drill_fields: [detail*]
}
measure: refund_count {
type: count
drill_fields: [id, customers.id, invoices.id, invoices.count, refunds.count]
filters: {
field: refunded
value: "Yes"
}
}
# ----- Sets of fields for drilling ------
set: detail {
fields: [
id,
captured,
amount,
amount_refunded,
currency,
paid,
invoice_id,
failure_code,
received_time,
created_time,
customers.email
]
}
}