BI
Business Intelligence
Analyzing data to support business decision-making. Tableau and Power BI are representative tools.
Business Intelligence
Analyzing data to support business decision-making. Tableau and Power BI are representative tools.
Business Intelligence (BI) is the collective term for the technologies, processes, and tools that collect, store, and analyze an organization's data and turn it into insights that can be used for decision-making. It uses past data to understand the current situation (Descriptive), analyzes why things happened (Diagnostic), and predicts the future (Predictive).
The core of modern BI is self-service BI. In the past, only the IT department or data specialists performed analysis, but now business users can explore and visualize data themselves. Tools such as Tableau, Power BI, Looker, and Metabase simplify complex analysis with drag-and-drop interfaces.
Data infrastructure is essential for effective BI implementation. Data is collected through ETL/ELT pipelines, stored in a data warehouse (BigQuery, Snowflake, Redshift), and given an analysis-optimized structure through data modeling (Star Schema, Snowflake Schema). The Semantic Layer connects business terms with technical data to provide consistent metric definitions.
BI is evolving toward Embedded Analytics and Augmented Analytics. Embedded Analytics builds BI capabilities into your own application so users get insights without a separate tool. Augmented Analytics uses AI/ML to automatically detect anomalies, query data with natural-language questions, and recommend insights.
# BI ๋์๋ณด๋ ์ค๊ณ ์์น ๋ฐ ๊ตฌํ ์์
# ============================================
# 1. ํจ๊ณผ์ ์ธ ๋์๋ณด๋ ์ค๊ณ ์์น
# ============================================
"""
[๋์๋ณด๋ ์ค๊ณ 5์์น]
1. ๋ชฉ์ ๋ช
ํํ (Purpose)
- ๋๊ฐ ์ฌ์ฉํ๋? (๊ฒฝ์์ง, ์ด์ํ, ๋ถ์๊ฐ)
- ์ด๋ค ์ง๋ฌธ์ ๋ตํด์ผ ํ๋?
- ์ด๋ค ํ๋์ ์ ๋ํ๋?
2. ์ ๋ณด ๊ณ์ธตํ (Hierarchy)
- ๊ฐ์ฅ ์ค์ํ ์งํ๋ฅผ ์๋จ/์ข์ธก์ ๋ฐฐ์น
- ์์ฝ โ ์์ธ ์์๋ก ๋๋ฆด๋ค์ด
- 3์ด ๋ด ํต์ฌ ๋ฉ์์ง ์ ๋ฌ
3. ์๊ฐํ ์ ํ (Visualization)
- ๋น๊ต: ๋ง๋ ์ฐจํธ
- ์ถ์ธ: ๋ผ์ธ ์ฐจํธ
- ๊ตฌ์ฑ: ํ์ด/๋๋ ์ฐจํธ
- ๋ถํฌ: ํ์คํ ๊ทธ๋จ/๋ฐ์คํ๋กฏ
- ๊ด๊ณ: ์ฐ์ ๋
4. ์ธํฐ๋ํฐ๋ธ (Interactive)
- ํํฐ๋ก ์ธ๊ทธ๋จผํธ ํ์
- ๋๋ฆด๋ค์ด์ผ๋ก ์์ธ ๋ถ์
- ํดํ์ผ๋ก ์ถ๊ฐ ์ ๋ณด ์ ๊ณต
5. ์ฑ๋ฅ ์ต์ ํ (Performance)
- ์ฌ์ ์ง๊ณ๋ ๋ฐ์ดํฐ ์ฌ์ฉ
- ์ฆ๋ถ ๋ก๋ฉ ๊ตฌํ
- ์บ์ฑ ์ ๋ต ์๋ฆฝ
"""
# ============================================
# 2. Semantic Layer ์ ์ (dbt Metrics)
# ============================================
# models/metrics/revenue_metrics.yml
"""
version: 2
metrics:
- name: total_revenue
label: Total Revenue
model: ref('fct_orders')
description: "์ด ๋งค์ถ์ก"
calculation_method: sum
expression: order_amount
timestamp: order_date
time_grains: [day, week, month, quarter, year]
dimensions:
- product_category
- region
- channel
filters:
- field: order_status
operator: '='
value: "'completed'"
- name: average_order_value
label: Average Order Value
model: ref('fct_orders')
description: "ํ๊ท ์ฃผ๋ฌธ ๊ธ์ก"
calculation_method: average
expression: order_amount
timestamp: order_date
time_grains: [day, week, month]
dimensions:
- product_category
- customer_segment
- name: conversion_rate
label: Conversion Rate
model: ref('fct_user_events')
description: "๊ตฌ๋งค ์ ํ์จ"
calculation_method: derived
expression: "{{metric('purchases')}} / {{metric('page_views')}}"
timestamp: event_date
time_grains: [day, week, month]
"""
# ============================================
# 3. Python์ผ๋ก ๋์๋ณด๋ ๋ฐ์ดํฐ ์ค๋น
# ============================================
import pandas as pd
import numpy as np
from datetime import datetime, timedelta
def prepare_executive_dashboard_data(conn):
"""๊ฒฝ์์ง ๋์๋ณด๋์ฉ ๋ฐ์ดํฐ ์ค๋น"""
# ํต์ฌ KPI ์ง๊ณ
kpi_query = """
WITH current_period AS (
SELECT
SUM(revenue) as total_revenue,
COUNT(DISTINCT customer_id) as unique_customers,
COUNT(*) as total_orders,
SUM(revenue) / COUNT(*) as aov
FROM orders
WHERE order_date >= DATE_TRUNC('month', CURRENT_DATE)
),
previous_period AS (
SELECT
SUM(revenue) as total_revenue,
COUNT(DISTINCT customer_id) as unique_customers,
COUNT(*) as total_orders,
SUM(revenue) / COUNT(*) as aov
FROM orders
WHERE order_date >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month')
AND order_date < DATE_TRUNC('month', CURRENT_DATE)
)
SELECT
c.total_revenue,
c.unique_customers,
c.total_orders,
c.aov,
(c.total_revenue - p.total_revenue) / p.total_revenue * 100 as revenue_growth,
(c.unique_customers - p.unique_customers) / p.unique_customers * 100 as customer_growth
FROM current_period c, previous_period p
"""
kpis = pd.read_sql(kpi_query, conn)
# ์ผ๋ณ ํธ๋ ๋
trend_query = """
SELECT
DATE(order_date) as date,
SUM(revenue) as daily_revenue,
COUNT(*) as daily_orders,
COUNT(DISTINCT customer_id) as daily_customers
FROM orders
WHERE order_date >= CURRENT_DATE - INTERVAL '30 days'
GROUP BY DATE(order_date)
ORDER BY date
"""
trends = pd.read_sql(trend_query, conn)
# ์นดํ
๊ณ ๋ฆฌ๋ณ ๋ถํฌ
category_query = """
SELECT
product_category,
SUM(revenue) as revenue,
COUNT(*) as orders,
SUM(revenue) / SUM(SUM(revenue)) OVER() * 100 as revenue_share
FROM orders o
JOIN products p ON o.product_id = p.product_id
WHERE order_date >= DATE_TRUNC('month', CURRENT_DATE)
GROUP BY product_category
ORDER BY revenue DESC
"""
categories = pd.read_sql(category_query, conn)
return {
'kpis': kpis.to_dict('records')[0],
'trends': trends.to_dict('records'),
'categories': categories.to_dict('records')
}
# ============================================
# 4. Looker LookML ์์
# ============================================
"""
# views/orders.view.lkml
view: orders {
sql_table_name: `project.dataset.orders` ;;
dimension: order_id {
primary_key: yes
type: string
sql: ${TABLE}.order_id ;;
}
dimension_group: order {
type: time
timeframes: [raw, date, week, month, quarter, year]
sql: ${TABLE}.order_date ;;
}
dimension: customer_id {
type: string
sql: ${TABLE}.customer_id ;;
}
dimension: revenue {
type: number
sql: ${TABLE}.revenue ;;
value_format_name: usd
}
dimension: revenue_tier {
type: tier
tiers: [0, 50, 100, 500, 1000]
style: integer
sql: ${revenue} ;;
}
measure: total_revenue {
type: sum
sql: ${revenue} ;;
value_format_name: usd_0
drill_fields: [order_id, customer_id, revenue]
}
measure: average_order_value {
type: average
sql: ${revenue} ;;
value_format_name: usd
}
measure: order_count {
type: count_distinct
sql: ${order_id} ;;
}
measure: customer_count {
type: count_distinct
sql: ${customer_id} ;;
}
}
# explores/orders.explore.lkml
explore: orders {
label: "Orders Analysis"
description: "์ฃผ๋ฌธ ๋ฐ์ดํฐ ๋ถ์"
join: customers {
type: left_outer
sql_on: ${orders.customer_id} = ${customers.customer_id} ;;
relationship: many_to_one
}
join: products {
type: left_outer
sql_on: ${orders.product_id} = ${products.product_id} ;;
relationship: many_to_one
}
}
"""
# ============================================
# 5. Tableau Prep ๋ฐ์ดํฐ ์ค๋น (Python ๋์)
# ============================================
def prepare_tableau_extract(source_df):
"""Tableau์ฉ ๋ฐ์ดํฐ ์ถ์ถ ์ค๋น"""
df = source_df.copy()
# ๋ ์ง ํ๋ ํ์ฑ
df['order_date'] = pd.to_datetime(df['order_date'])
df['order_year'] = df['order_date'].dt.year
df['order_month'] = df['order_date'].dt.month
df['order_week'] = df['order_date'].dt.isocalendar().week
df['order_day_of_week'] = df['order_date'].dt.day_name()
# ๊ณ์ฐ ํ๋ ์ถ๊ฐ
df['revenue_per_item'] = df['revenue'] / df['quantity']
df['is_high_value'] = df['revenue'] > df['revenue'].quantile(0.75)
# ์ธ๊ทธ๋จผํธ ์์ฑ
df['customer_segment'] = pd.cut(
df.groupby('customer_id')['revenue'].transform('sum'),
bins=[0, 100, 500, 1000, float('inf')],
labels=['Bronze', 'Silver', 'Gold', 'Platinum']
)
# ์ด์์น ํ๋๊ทธ
df['is_outlier'] = (
(df['revenue'] < df['revenue'].quantile(0.01)) |
(df['revenue'] > df['revenue'].quantile(0.99))
)
return df
# ============================================
# 6. Embedded Analytics API ์์
# ============================================
import requests
import jwt
from datetime import datetime, timedelta
class EmbeddedBIClient:
"""Embedded BI ํด๋ผ์ด์ธํธ (Looker ์คํ์ผ)"""
def __init__(self, base_url, client_id, client_secret):
self.base_url = base_url
self.client_id = client_id
self.client_secret = client_secret
self.access_token = None
def authenticate(self):
"""OAuth2 ์ธ์ฆ"""
response = requests.post(
f"{self.base_url}/api/4.0/login",
data={
'client_id': self.client_id,
'client_secret': self.client_secret
}
)
self.access_token = response.json()['access_token']
def create_embed_url(self, dashboard_id, user_attributes, embed_domain):
"""SSO Embed URL ์์ฑ"""
embed_params = {
'resource': {'dashboard': dashboard_id},
'user': {
'first_name': user_attributes.get('first_name', 'User'),
'last_name': user_attributes.get('last_name', ''),
'permissions': ['access_data', 'see_user_dashboards'],
'models': ['orders'],
'user_attributes': {
'company_id': user_attributes.get('company_id'),
'region': user_attributes.get('region')
}
},
'embed_domain': embed_domain,
'session_length': 3600,
'force_logout_login': True
}
# JWT ํ ํฐ ์์ฑ
token = jwt.encode(
{
**embed_params,
'exp': datetime.utcnow() + timedelta(hours=1)
},
self.client_secret,
algorithm='HS256'
)
return f"{self.base_url}/embed/dashboards/{dashboard_id}?embed_token={token}"
def run_query(self, model, view, fields, filters=None, sorts=None, limit=500):
"""์ฟผ๋ฆฌ ์คํ"""
query_body = {
'model': model,
'view': view,
'fields': fields,
'filters': filters or {},
'sorts': sorts or [],
'limit': limit
}
response = requests.post(
f"{self.base_url}/api/4.0/queries/run/json",
headers={'Authorization': f'Bearer {self.access_token}'},
json=query_body
)
return response.json()
# ์ฌ์ฉ ์์
"""
client = EmbeddedBIClient(
base_url='https://your-looker-instance.com',
client_id='your_client_id',
client_secret='your_client_secret'
)
client.authenticate()
# ๋์๋ณด๋ ์๋ฒ ๋ URL ์์ฑ
embed_url = client.create_embed_url(
dashboard_id='sales_overview',
user_attributes={
'company_id': 'ACME',
'region': 'APAC'
},
embed_domain='https://your-app.com'
)
"""
print("BI ๋์๋ณด๋ ์ค๊ณ ์์ ์๋ฃ")
Business analyst: "I'm creating the sales report manually every time. Can we automate it?"
Data engineer: "If you build a dashboard with Looker or Metabase, it updates in real time and you can also set up automatic email delivery. If you first list the metrics you look at often, I'll define them in the Semantic Layer."
Business analyst: "Each department looks at things differently, so even the same metric is sometimes defined differently."
Data engineer: "That's why the Semantic Layer matters. If you create standard metric definitions used company-wide and have every dashboard reference the same definitions, consistency is maintained."
Interviewer: "What principles do you consider most important in designing an effective BI dashboard?"
Candidate: "The most important thing is clarifying the purpose. An executive dashboard should show 3-5 key KPIs at a glance, while one for the operations team should focus on real-time monitoring and alerts. Information hierarchy is also important: put the most important metric in the top left and allow detailed analysis through drill-down. Finally, performance. However good a dashboard is, people stop using it if it takes more than 5 seconds to load, so pre-aggregation and caching strategies are essential."
Take a mock interview on this topic โ WIA SOOM AI Interview ยท Start for free
Reviewer: "The dashboard has as many as 15 metrics. That seems like too many."
Developer: "I included everything as users requested. Should I cut it down?"
Reviewer: "According to Miller's Law, people can process about 7 pieces of information at a time. It would be better to place 5 key KPIs large at the top and separate the rest into tabs or drill-downs. Also, combining similar metrics such as DAU and WAU into a single chart saves space and makes comparison easier."