forked from teamdatatonic/looker-date-comparison
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathyour_model.model.lkml
43 lines (32 loc) · 1.15 KB
/
your_model.model.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
connection: "sandbox"
# include all the views
include: "*.view"
explore: your_view_name {
#---- This is an example explore file
#---- Add in this sql_always_where clause replacing your_view_name
sql_always_where:
{% if your_view_name.current_date_range._is_filtered %}
(
{% condition your_view_name.current_date_range %} (${event_raw}) {% endcondition %}
{% if your_view_name.previous_date_range._is_filtered or your_view_name.compare_to._in_query %}
{% if your_view_name.comparison_periods._parameter_value == "2" %}
or
${event_raw} between ${period_2_start} and ${period_2_end} )
{% elsif your_view_name.comparison_periods._parameter_value == "3" %}
or
${event_raw} between ${period_2_start} and ${period_2_end}
or
${event_raw} between ${period_3_start} and ${period_3_end} )
{% elsif your_view_name.comparison_periods._parameter_value == "4" %}
or
${event_raw} between ${period_2_start} and ${period_2_end}
or
${event_raw} between ${period_3_start} and ${period_3_end}
or
${event_raw} between ${period_4_start} and ${period_4_end} )
{% else %} AND 1 = 1 )
{% endif %}
{% endif %}
{% else %} 1 = 1
{% endif %} ;;
}