← All use cases
KPI cards in Slack, Excel and PDF attached
Put the numbers people need in the channel they read. DRE builds Slack Block Kit cards and charts from query results, with reusable .json components for the layout. The daily KPI demo posts revenue, orders and average order value, a 14-day revenue chart, and Excel and PDF files from the same data.
What it produces



How it’s built
The report’s SQL and YAML, as they sit in the project, and the commands that run it. A complete, runnable version is in the public examples (linked above).
queries: [daily_kpis_days]
output:
- name: workbook
format: xlsx
queries: [daily_kpis_days]
destination: {profile: local, path: "out/messages/daily_kpis.xlsx"}
- name: summary_pdf
format: pdf
template: {file: daily_kpis.html}
destination: {profile: local, path: "out/messages/daily_kpis.pdf"}
- name: kpis
format: message
title: "Daily KPIs"
text: "Daily KPIs for {{ results.daily_kpis_days.rows[-1].day }}"
destination:
- profile: local
path: "out/messages/daily_kpis.md"
default_set: files
sets:
- name: files
- name: slack
output:
name: kpis
destination:
- profile: slack
attach: [workbook, summary_pdf]
files_in: message
blocks:
- {type: header, text: {type: plain_text, text: "Daily KPIs · {{ results.daily_kpis_days.rows[-1].day }}"}}
- component: kpi_cards.json
with: {query: daily_kpis_days}
- component: revenue_chart.json
with: {query: daily_kpis_days}
- type: context
elements: [{type: mrkdwn, text: "Sent by DRE · daily_kpis"}]queries: [msg_headline, msg_regions]
output:
- name: workbook
format: xlsx
queries: [msg_regions]
destination: {profile: local, path: "out/messages/regions-{{ run.date.yyyymmdd }}.xlsx"}
- name: headline
format: message
title: "{{ var('company') }}: {{ period(var('period')).start.format('%B %Y') }}"
text: |
Net revenue: **{{ results.msg_headline.first.net | currency('EUR') }}** ({{ results.msg_headline.first.change | percent | signed }} on the month before)
Orders: {{ results.msg_headline.first.orders | number }}
Top regions:
{% for r in results.msg_regions.rows[:3] %}- {{ r.region_name }}: {{ r.net | currency('EUR') }}
{% endfor %}
destination:
- {profile: slack, attach: [workbook]}{% set p = period(var('period')) %}
{% set before = period('last_month', as_of=p.start.date) %}
select
sum(net_amount) filter (where order_date between '{{ p.start.date }}' and '{{ p.end.date }}') as net,
count(distinct order_id) filter (where order_date between '{{ p.start.date }}' and '{{ p.end.date }}') as orders,
sum(net_amount) filter (where order_date between '{{ p.start.date }}' and '{{ p.end.date }}')
/ nullif(sum(net_amount) filter (where order_date between '{{ before.start.date }}' and '{{ before.end.date }}'), 0) - 1 as change
from {{ ref('paid_order_facts') }}dre run msg_daily --preview # print the message, send nothing
dre run msg_daily