in generator/views/funnel_analysis_view.py [0:0]
def _funnel_analysis_lookml(self) -> List[Dict[str, Any]]:
dimensions = [
{
"name": f"completed_step_{n}",
"type": "yesno",
"description": f"Whether the user completed step {n} on the associated day.",
"sql": dedent(
f"""
REGEXP_CONTAINS(
${{TABLE}}.events, mozfun.event_analysis.create_funnel_regex(
[{", ".join([
f'${{step_{ni}.match_string}}' for ni in range(1, n + 1)
])}],
True
)
)
"""
),
}
for n in range(1, self.n_events() + 1)
]
count_measures: List[Dict[str, Any]] = [
{
"name": f"count_completed_step_{n}",
"description": (
f"The number of times that step {n} was completed. "
"Grouping by day makes this a count of users who completed "
f"step {n} on each day."
),
"type": "count",
"filters": [{f"completed_step_{ni}": "yes"} for ni in range(1, n + 1)],
}
for n in range(1, self.n_events() + 1)
]
fractional_measures: List[Dict[str, Any]] = [
{
"name": f"fraction_completed_step_{n}",
"description": f"Of the user-days that completed Step 1, the fraction that completed step {n}.",
"type": "number",
"value_format": "0.00%",
"sql": f"SAFE_DIVIDE(${{count_completed_step_{n}}}, ${{count_completed_step_1}})",
}
for n in range(1, self.n_events() + 1)
]
return [
{
"name": "funnel_analysis",
"extends": ["events_daily_table"],
"dimensions": dimensions,
"measures": count_measures + fractional_measures,
}
]