-
Notifications
You must be signed in to change notification settings - Fork 0
/
measures_employee_daily.view.lookml
341 lines (265 loc) · 7.33 KB
/
measures_employee_daily.view.lookml
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
- view: measures_employee_daily
derived_table:
sql: |
SELECT emp.personid as personid
, timeperiods.date AS todate
, CAST(timeperiods.year as VARCHAR) + CAST(timeperiods.month as VARCHAR) as timeperiod
, emp.status
, emp.fullname
, emp.firstname
, emp.lastname
, date_diff('years', emp.dob, timeperiods.date) AS age
, date_diff('months', emp.hiredate, timeperiods.date) AS tenure_months
, CASE WHEN datepart(month, emp.dob) = datepart(month, timeperiods.date) AND datepart(day, emp.dob) = datepart(day, timeperiods.date) THEN 1 ELSE 0 END AS birthday_count
, emp.dob
, emp.gender
, emp.nationality
, emp.ethnicgroup as ethnic_group
, emp.eeojob as eeo_job
, emp.hiredate as hire_date
, emp.tenuredate as tenure_date
, emp.email
, emp.phone
, emp.salutation
, emp.country
, emp.state
, emp.city
, emp.building
, emp."level"
, emp.zip
, emp.department
, emp.costcenter
, emp.positionid as position_id
, emp.jobid as job_id
, emp.jobfamily as job_family
, emp.jobfunction as job_function
, emp.critical
, emp.manager
, emp.matrixmanager as matrix_manager
, emp.annualsalary as annual_salary
, emp.annualsalaryrange as annual_salary_range
, emp.bonus
, emp.hourlyrate as hourly_rate
, emp.performancerating as performance_rating
, emp.prevperfrating as prev_perf_rating
, emp.nineboxrating as ninebox_rating
, emp.emptype as emp_type
, emp.regtemp as reg_temp
, emp.fullpart as fullpart
, emp.contractor
, emp.riskofloss as risk_of_loss
, emp.impactofloss as impact_of_loss
, emp.ismanager as is_manager
, emp.headcount
, emp.fte
FROM one.employee emp
INNER JOIN one.timeperiods
ON emp.effdt <= timeperiods.date
AND emp.enddt >= timeperiods.date
AND emp.headcount = 1
fields:
- dimension: age
type: number
sql: ${TABLE}.age
- dimension: annualsalary
type: number
sql: ${TABLE}.annualsalary
- dimension: annualsalaryrange
sql: ${TABLE}.annualsalaryrange
- dimension: birthday_count
type: int
sql: ${TABLE}.birthday_count
- dimension: bonus
type: number
sql: ${TABLE}.bonus
- dimension: building
sql: ${TABLE}.building
- dimension: city
sql: ${TABLE}.city
- dimension: contractor
sql: ${TABLE}.contractor
- dimension: costcenter
sql: ${TABLE}.costcenter
- dimension: country
sql: ${TABLE}.country
- dimension: critical
sql: ${TABLE}.critical
- dimension: department
sql: ${TABLE}.department
- dimension_group: dob
type: time
timeframes: [date, week, month]
convert_tz: false
sql: ${TABLE}.dob
- dimension: eeojob
sql: ${TABLE}.eeojob
- dimension: email
sql: ${TABLE}.email
- dimension: emptype
sql: ${TABLE}.emptype
- dimension: ethnicgroup
sql: ${TABLE}.ethnicgroup
- dimension: firstname
sql: ${TABLE}.firstname
- dimension: fte
type: number
sql: ${TABLE}.fte
- dimension: fullname
sql: ${TABLE}.fullname
- dimension: fullpart
sql: ${TABLE}.fullpart
- dimension: gender
sql: ${TABLE}.gender
- dimension: headcount
type: int
sql: ${TABLE}.headcount
- dimension_group: hire_date
type: time
timeframes: [date, week, month, year]
convert_tz: false
sql: ${TABLE}.hire_date
- dimension: hourlyrate
type: number
sql: ${TABLE}.hourlyrate
- dimension: impactofloss
sql: ${TABLE}.impactofloss
- dimension: ismanager
type: yesno
sql: ${TABLE}.ismanager
- dimension: jobfamily
sql: ${TABLE}.jobfamily
- dimension: jobfunction
sql: ${TABLE}.jobfunction
- dimension: jobid
sql: ${TABLE}.jobid
- dimension: lastname
sql: ${TABLE}.lastname
- dimension: level
sql: ${TABLE}.level
- dimension: manager
sql: ${TABLE}.manager
- dimension: matrixmanager
sql: ${TABLE}.matrixmanager
- dimension: nationality
sql: ${TABLE}.nationality
- dimension: nineboxrating
sql: ${TABLE}.nineboxrating
- dimension: performancerating
sql: ${TABLE}.performancerating
- dimension: personid
sql: ${TABLE}.personid
- dimension: personrcdrank
type: int
sql: ${TABLE}.personrcdrank
- dimension: phone
sql: ${TABLE}.phone
- dimension: positionid
sql: ${TABLE}.positionid
- dimension: prevperfrating
sql: ${TABLE}.prevperfrating
- dimension: qualityhire
sql: ${TABLE}.qualityhire
- dimension: regtemp
sql: ${TABLE}.regtemp
- dimension: revseqnr
type: int
sql: ${TABLE}.revseqnr
- dimension: riskofloss
sql: ${TABLE}.riskofloss
- dimension: salutation
sql: ${TABLE}.salutation
- dimension: seqnr
type: int
sql: ${TABLE}.seqnr
- dimension: state
sql: ${TABLE}.state
- dimension: status
sql: ${TABLE}.status
- dimension: organization_tenure
type: number
sql: ${TABLE}.tenure_months
- dimension_group: tenuredate
type: time
timeframes: [date, week, month]
convert_tz: false
sql: ${TABLE}.tenuredate
- dimension_group: todate
type: time
timeframes: [date, week, month]
convert_tz: false
sql: ${TABLE}.todate
# - dimension_group: todate
# type: time
# timeframes: [year]
# convert_tz: false
# sql: ${TABLE}.todate
# html: Idea is to hack together a year -> month drillpath
- dimension: wkfid
type: int
sql: ${TABLE}.wkfid
- dimension: zip
sql: ${TABLE}.zip
### Core daily metrics
- measure: headcount_daily
type: sum
sql: ${headcount}
- measure: total_age_daily
type: sum
sql: ${age}
decimals: 2
- measure: average_age_daily
type: average
sql: 1.00 * ${age}
decimals: 1
- measure: average_age_daily2
type: number
sql: 1.00 * sum(${age}) / sum(${headcount})
decimals: 1
- measure: average_tenure_daily
type: average
sql: (1.0 * ${organization_tenure}) / 12.0
decimals: 1
- measure: headcount_daily_male
type: sum
sql: ${headcount}
filters:
gender: 1
- measure: headcount_daily_female
type: sum
sql: ${headcount}
filters:
gender: 2
- measure: male_to_female_staffing_ratio
type: number
sql: 1.00 * ${headcount_daily_male} / NULLIF(${headcount_daily_female}, 0)
decimals: 2
- measure: staffing_rate_male
type: number
sql: 100.00 * ${headcount_daily_male} / NULLIF(${headcount_daily}, 0)
format: "%5.2f%%"
- measure: staffing_rate_female
type: number
sql: 100.00 * ${headcount_daily_female} / NULLIF(${headcount_daily}, 0)
format: "%5.2f%%"
- measure: birthdays_total
type: sum
sql: ${birthday_count}
- measure: hire_anniversaries
type: sum
sql: CASE WHEN datepart(month, hire_date) = datepart(month, todate) AND datepart(day, hire_date) = datepart(day, todate) THEN 1 ELSE 0 END
# DW - Testing some daily aggregation
# - measure: base_fte
# type: sum
# sql: ${TABLE}.fte
#
# - measure: days_so_far
# type: count_distinct
# sql: ${TABLE}.todate
#
# - measure: full_time_equivlent
# type: number
# sql: ${base_fte} / ${days_so_far}
#
# - measure: average_hc
# type: number
# sql: ${headcount_sum} / ${days_so_far}