-
Notifications
You must be signed in to change notification settings - Fork 0
/
events_with_cumulative_hc.view.lookml
103 lines (85 loc) · 3.12 KB
/
events_with_cumulative_hc.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
- explore: events_with_cumulative_hc
- view: events_with_cumulative_hc
derived_table:
sql: |
SELECT
DATE(employee_event.effdt) AS "employee_event.effdt_date",
employee_event.eventid AS "employee_event.eventid",
employee.department AS "employee.department",
employee.gender AS "employee.gender",
employee.positionid AS "employee.positionid",
dim_event_reason.level1desc AS "dim_event_reason.level1desc",
SUM(CASE WHEN dim_event_reason.level1desc = 'Hire'
THEN 1 ELSE 0 END)
OVER (order by DATE(employee_event.effdt) rows unbounded preceding)
AS "employee_event.cumulative_hires",
SUM(CASE WHEN dim_event_reason.level1desc LIKE '%Termination%'
THEN 1 ELSE 0 END)
OVER (order by DATE(employee_event.effdt) rows unbounded preceding)
AS "employee_event.cumulative_terminations",
SUM(CASE WHEN dim_event_reason.level1desc = 'Hire'
THEN 1 ELSE 0 END)
OVER (order by DATE(employee_event.effdt) rows unbounded preceding)
- SUM(CASE WHEN dim_event_reason.level1desc LIKE '%Termination%'
THEN 1 ELSE 0 END)
OVER (order by DATE(employee_event.effdt) rows unbounded preceding)
AS "employee_event.current_headcount"
FROM one.employee_event AS employee_event
LEFT JOIN one.employee AS employee ON employee_event.wkfid = employee.wkfid
LEFT JOIN one.dim_event_reason AS dim_event_reason ON employee_event.eventreason = dim_event_reason.id
WHERE {% condition employee_gender %} employee.gender {% endcondition %}
GROUP BY 1,2,3,4,5,6
ORDER BY 1
fields:
- measure: count
type: count
detail: detail*
- dimension_group: event_eff
type: time
timeframes: [date, week, month]
sql: ${TABLE}."employee_event.effdt_date"
- dimension: event_id
type: number
sql: ${TABLE}."employee_event.eventid"
- dimension: employee_department
sql: ${TABLE}."employee.department"
- dimension: employee_gender
sql: ${TABLE}."employee.gender"
- dimension: employee_position_id
sql: ${TABLE}."employee.positionid"
- dimension: event_type
sql: ${TABLE}."dim_event_reason.level1desc"
- measure: total_hires
type: count
filters:
event_type: 'Hire'
detail: detail*
- measure: total_terminations
type: count
filters:
event_type: '%Termination%'
detail: detail*
- measure: termination_rate
type: number
format: '%0.2f%'
sql: 100.0 * ${total_terminations} / NULLIF(${average_headcount},0)
- dimension: cumulative_hires
type: number
sql: ${TABLE}."employee_event.cumulative_hires"
- dimension: cumulative_terminations
type: number
sql: ${TABLE}."employee_event.cumulative_terminations"
- dimension: current_headcount
type: number
sql: ${TABLE}."employee_event.current_headcount"
- measure: average_headcount
type: average
sql: ${current_headcount}
sets:
detail:
- event_eff_date
- event_id
- employee_department
- employee_gender
- employee_position_id
- event_type