So the metrics/KPIs we are looking to capture are here: Total Published Articles Percent of KBAs Viewed - Last Month Number of times KBAs were attached to Tickets - Last Month Article Quality Index Contribution Index FCR Rate % f KBA marked as Helpful - Article Link Accuracy Ticket Deflection Rate Change in Participation Rate # of articles updated (modified) # of Articles Retired # Articles created from Ticket Management % of Articles reviewed and improved
To upload files, please first save the app
import streamlit as st
import pandas as pd
import numpy as np
import plotly.graph_objects as go
from datetime import datetime, timedelta
# Sample data generation
def generate_sample_data():
current_month = datetime.now()
last_month = current_month - timedelta(days=30)
data = {
'total_published': 1250,
'kba_viewed_last_month': 0.78, # 78%
'kba_ticket_attachments': 456,
'article_quality_index': 0.85, # 85%
'contribution_index': 0.72, # 72%
'fcr_rate': 0.65, # 65%
'helpful_rate': 0.92, # 92%
'deflection_rate': 0.45, # 45%
'participation_rate_change': 0.15, # +15%
'articles_updated': 89,
'articles_retired': 12,
'articles_from_tickets': 34,
'articles_reviewed': 0.88, # 88%
}
return data
# Page layout
st.set_page_config(page_title="Knowledge Base Analytics", layout="wide")
st.title("Knowledge Base Analytics Dashboard")
# Generate sample data
data = generate_sample_data()
# Create three columns for metrics
col1, col2, col3 = st.columns(3)
# Column 1 metrics
with col1:
st.metric(
label="Total Published Articles",
value=data['total_published'],
delta=f"+{15} this month"
)
st.metric(
label="KBAs Viewed Rate (Last Month)",
value=f"{data['kba_viewed_last_month']:.0%}",
delta=f"{5}%"
)
st.metric(
label="Article Quality Index",
value=f"{data['article_quality_index']:.0%}",
delta=f"{3}%"
)
st.metric(
label="Ticket Deflection Rate",
value=f"{data['deflection_rate']:.0%}",
delta=f"{7}%"
)
# Column 2 metrics
with col2:
st.metric(
label="KBAs Attached to Tickets",
value=data['kba_ticket_attachments'],
delta=f"+{23} vs last month"
)
st.metric(
label="FCR Rate",
value=f"{data['fcr_rate']:.0%}",
delta=f"{4}%"
)
st.metric(
label="Articles Updated",
value=data['articles_updated'],
delta=f"+{12} this month"
)
st.metric(
label="Articles from Tickets",
value=data['articles_from_tickets'],
delta=f"+{8} this month"
)
# Column 3 metrics
with col3:
st.metric(
label="Contribution Index",
value=f"{data['contribution_index']:.0%}",
delta=f"{6}%"
)
st.metric(
label="Articles Marked Helpful",
value=f"{data['helpful_rate']:.0%}",
delta=f"{2}%"
)
st.metric(
label="Articles Retired",
value=data['articles_retired'],
delta=f"-{3} this month"
)
st.metric(
label="Articles Reviewed",
value=f"{data['articles_reviewed']:.0%}",
delta=f"{5}%"
)
# Create trend charts
st.subheader("Monthly Trends")
# Sample monthly data for trends
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
article_creation = [45, 52, 61, 58, 65, 72]
article_usage = [320, 350, 410, 380, 450, 480]
# Create two columns for charts
chart_col1, chart_col2 = st.columns(2)
with chart_col1:
fig1 = go.Figure()
fig1.add_trace(go.Scatter(x=months, y=article_creation, mode='lines+markers', name='New Articles'))
fig1.update_layout(title='Article Creation Trend', xaxis_title='Month', yaxis_title='Count')
st.plotly_chart(fig1, use_container_width=True)
with chart_col2:
fig2 = go.Figure()
fig2.add_trace(go.Bar(x=months, y=article_usage, name='Article Usage'))
fig2.update_layout(title='Article Usage Trend', xaxis_title='Month', yaxis_title='Views')
st.plotly_chart(fig2, use_container_width=True)
# Add filters
st.sidebar.header("Filters")
date_range = st.sidebar.selectbox(
"Time Period",
["Last 30 Days", "Last Quarter", "Last 6 Months", "Last Year"]
)
article_type = st.sidebar.multiselect(
"Article Type",
["How-to", "Troubleshooting", "Feature Documentation", "Release Notes"],
["How-to", "Troubleshooting"]
)
department = st.sidebar.multiselect(
"Department",
["Sales", "Support", "Engineering", "Product"],
["Support", "Engineering"]
)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?